Fixed Background Solution

jump222

New Member
I'm a new designer using Dreamweaver CS4 and I'm trying to create a fixed background with logo and navigation bar staying stationary at the top of the page while my images can scroll in a table horizontally under them. I've tried everything but no luck. I have a site that I want to emulate, I can provide the URL to help explain what I need. Any help is greatly appreciated!
 

PixelPusher

Super Moderator
Staff member
A link would be great :D

For a fixed background at the top center just use:
Code:
body {
background:#color url(yourImage.png) top center no-repeat;
}

To fix a navigation bar to the top of your page use positioning:

CSS Positioning
Code:
ul.menu {
width:960px;
position:relative;
top:0;
left:50%;
padding:0;
margin-top:0;
margin-right:0;
margin-bottom:0;
margin-left:-480px;
/* margin:0 0 0 -480px; */  (shorthand method)
}

There are three different types of positioning you can use:
  • Relative (used above) - this will position the menu based on its top, right, bottom, left values relative to its previous neighbor. If it is the first item on the page, then the neighbor will be the html.
  • Absolute - this will position the menu absolutely based on the T,R,B,L values to the parent element that HAS a set position other than static. If no parent exist then it will position itself to the html.
  • Fixed - this will position the menu fixed based in the T,R,B,L to the html nomatter what. It will overlay any other element that is not fixed, or any other fixed element that has a lower z-index value.

You can read more about positioning on W3 schools website under the CSS section.
 

tevih

New Member
First of all, can someone kick out "Technoblue" for constantly spamming the forums??

The code above does not help with fixed background - that positions the background in the right location, top right, but for a fixed background (where it doesn't move when the page scrolls) do:

Code:
background:#ff0000 url('smiley.gif') no-repeat fixed top center;
 
Top