Jump to content

[SOLVED] How to fix the placement of a div layer


ksduded

Recommended Posts

I want to make a div fixed on the top of my page. All the content will be in another Div which can be scrolled down. But the fixed div always remain on the top.

 

This is what i have defined so far in css. (Layout is the main layer which has the statictopbar div nested within it). I want to make the statictopbar div as the a fixed div at the top of the page, and everything flows under it. I also need to position it at the horizontal center of the page.

 

html, body {
margin:0;
padding:0;
height:100%;
}

.layout 
{
position:relative;
margin: 0 auto;
border:solid 1px #000000;
border-bottom:0;
border-top:0;
width:762px;
min-height:100%;
}

.statictopbar
{
font-family: "Century Gothic";
font-size: 12px;
color: #999999;
background-color: #000000;
height: 114px;
border:solid 0px #000000;
width:762px;
position: absolute;
top:0;
left:0;
}

Link to comment
Share on other sites

position:fixed;

 

this don't work in IE6 so you'll need a bit of javascript to help out...

 

if I make it fixed, I have to provide the x and y position. y is fine as top:0; but I need to position it horizontally regardless of the resolution, so x property is dynamic. Can I define a variable for changing the x property in CSS according to the user's resolution.

Link to comment
Share on other sites

yeah i used this

 

#statictopbar
{
font-family: "Century Gothic";
font-size: 12px;
color: #999999;
background-color: #000000;
height: 114px;
border:solid 0px #000000;
width:762px;
position: fixed;
top:0;
left:50%;
margin-left:-381px;

}

 

and now it works

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.