Forum Moderators: not2easy

Message Too Old, No Replies

div background positioning

         

mlord06

7:16 pm on Jul 26, 2010 (gmt 0)

10+ Year Member



The Div is positioned on the far left when it shows up as the far left in chrome when it looks directly under center in Dreamweaver. (Like I want it) Here's the code:

@charset "utf-8";
/* CSS Document */

#Container {
width: 1024px;
background-image: url(images/tbl_BG.gif);
background-repeat: no-repeat;
}
#Content {
width: 800px;
margin-left: 125px;
}
.HeaderImage1 {
margin-left: 695px;
}
#NavBar {
margin-left: 15px;

}
#Top {
background-image: url(images/HeaderBG.jpg);
background-repeat: no-repeat;
margin-top: 30px;
}

CWonder

2:45 am on Jul 27, 2010 (gmt 0)

10+ Year Member



Never believe dreamweaver, I find that the design view is highly innacurate and horrible at rendering complex layouts. Could you show an example so it can be better trouble shooted.

If you are just trying to center your container div u can do :

#Container {
width: 1024px;
background-image: url(images/tbl_BG.gif);
background-repeat: no-repeat;
margin: 0 auto;
}

Major_Payne

12:18 pm on Jul 27, 2010 (gmt 0)



If you are wanting divs centered which have background images, you might try this:


#Container {
width: 1024px;
margin: 0 auto;
background-image: url(images/tbl_BG.gif) no-repeat center scroll;
}

#Top {
width: #*$!px;
margin: 0 auto;
margin-top: 30px;
background-image: url(images/HeaderBG.jpg) no-repeat center scroll;
}


Those may need heights set to show the background images as you want. To center anything, a width less than 100% must be given. Then the CSS property, margin: 0 auto;, can be used.

If the following is being centered in its container, then margin-left is not needed:
.HeaderImage1 {
margin-left: 695px;
}


If that div is to contain an image, then you need to set a width/height for it. Since I see it contains no background image, be sure to include the full width/height attributes for the image tag.

Ron