Welcome to Dream.In.Code
Become an Expert!

Join 149,487 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,329 people online right now. Registration is fast and FREE... Join Now!




Div background color issue

 
Reply to this topicStart new topic

Div background color issue

matt-the-mash
16 May, 2007 - 01:28 AM
Post #1

D.I.C Head
**

Joined: 10 Jul, 2006
Posts: 120



Thanked: 1 times
My Contributions
This is probably really simple, but when i produce a layout using DIV, and styling with CSS, i can align the DIV's and set font's etc no problem.

But when i use by HTML editor, i can set the background color of the DIV and it fills fine, but when i upload and to the server and run on the web, the background color does'nt fill all the way down.

The background color for the div#nav fills ok, its just the #container div that does'nt seem to work.
Here is the code for the styles and layout:

CODE

<style type="text/css" media="screen">

div#container {
margin: 0 auto; width: 80%;
height: 100%;
background-color:#FDCFAE;
z-index:100;
}

div#content {
width:100%;
height:100%;
background-color:#FDCFAE;
z-index:101;

}

div#nav {
background-color:#F79E5D;
border-style:solid;
border-color:orange;
font-family: arial;
font-size:8;
text-align:center;
}

div#banner {
z-index: 103; left: 110px; width: 344px; position: absolute; top: 51px;
        height: 64px
}
</style>
</head>

<body>
     
    
<div id="container">
     
    <div id="content">
        <div id="nav" style="z-index: 102; left: 121px; width: 175px; position: absolute; top: 127px;
            height: 194px">
            <a href="http://www.book-your-mot.co.uk">book-your-mot.co.uk</a>
        </div>
  <div id="banner">
       <img src="/images/bookmy_banner1.jpg" style="width:100%;" />
    </div>  

</div><!--content-->
</div><!--container-->
</body>
</html>

User is offlineProfile CardPM
+Quote Post

DilutedImage
RE: Div Background Color Issue
16 May, 2007 - 04:40 PM
Post #2

D.I.C Addict
Group Icon

Joined: 20 Nov, 2006
Posts: 643



Thanked: 6 times
Dream Kudos: 25
My Contributions
What browser are you viewing this in? Not all browsers (IE6) support the height attribute in DIVs. To work around this, you can create a background that is as tall as the minimum height you want the DIV to be (perhaps a 1px wide transparent GIF). You could also use padding to force it X pixels beyond the content.


User is offlineProfile CardPM
+Quote Post

Arbitrator
RE: Div Background Color Issue
18 May, 2007 - 12:50 PM
Post #3

D.I.C Regular
Group Icon

Joined: 26 Jan, 2005
Posts: 492



Thanked: 1 times
My Contributions
Let’s see: Absolutely positioned elements aren’t in the normal flow, so #content behaves as if it has no content. Thus, the background is not drawn because there’s nowhere to draw it to. You might think that #content has dimensions greater than zero by zero, because you’ve assigned it a height of 100%; however, percentage heights are ignored unless an ancestor has an explicit height. Since neither body nor html have been assigned explicit or percentage heights…
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 04:58PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month