Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I display the "first time here" bar like SO and slide the other DIVs down?

Tags:

jquery

css

I implemented the code to dislay the bar at the top of the stackoverflow screen: How to show popup message like in stackoverflow

What this does is display the div over top of the div at the top of the page. How can I display the new "bar" div and push the others down? Just like StackOverflow does.

like image 800
ScottG Avatar asked May 04 '10 20:05

ScottG


2 Answers

Don't use the "position: fixed" property in css, try "absolute" from: http://www.w3schools.com/css/pr_class_position.asp

Fixed position is relative to your "viewport" (browser window).

Absolute position is relative to your html document.

like image 185
dlamotte Avatar answered Sep 30 '22 11:09

dlamotte


Edit: The immediate reaction to my code below will be to not use the div#removeme tag and instead provide a margin-bottom. However if you are going with position:fixed this won't work as it attaches itself to the window and not the document.


This is what i do:

In my html document:

<div id="removeme">
    <br /><br />
</div>

<div id="header"> This is a floating pane! </div>
<div id="content"> Your content goes here... </div>

The CSS for this floating pane is:

 #header {
   position: fixed;
   top: 0px;
   left: 0px;
   text-align: center;
   background-color: #FFE6BF;
   height: 30px;
   border: 1px solid #FFCFA6;
   width: 100%;
  }

And then use jquery in the <head> tag:

$(document).ready(function() {
 $('#header').click(function() {
  $('#header').slideUp('fast');
  $('#removeme').remove();
 });
});

I have an extra <div> tag with id removeme to push the contents down when the floating pane is visible and i remove it whenever the floating pane is hidden.

like image 30
Shripad Krishna Avatar answered Sep 30 '22 11:09

Shripad Krishna