...

View Full Version : DIV background-image is not showing up



stefonia
01-26-2008, 06:03 PM
My entire website is structured with DIV and in the footer are two more float:left DIV to separate some text. I placed a background image in my footer DIV and mainContent DIV but they won't show up. While the background image in my header DIV did.
Any help would be appreciated!

STYLESHEET


@charset "UTF-8";
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}

/* Tips for Elastic layouts
1. Since the elastic layouts overall sizing is based on the user's default fonts size, they are more unpredictable. Used correctly, they are also more accessible for those that need larger fonts size since the line length remains proportionate.
2. Sizing of divs in this layout are based on the 100% font size in the body element. If you decrease the text size overall by using a font-size: 80% on the body element or the #container, remember that the entire layout will downsize proportionately. You may want to increase the widths of the various divs to compensate for this.
3. If font sizing is changed in differing amounts on each div instead of on the overall design (ie: #sidebar1 is given a 70% font size and #mainContent is given an 85% font size), this will proportionately change each of the divs overall size. You may want to adjust based on your final font sizing.
*/
.columns #topborder {
width: 100%; /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */
height: 5px;
background: #0099FF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
text-align: left; /* this overrides the text-align: center on the body element. */
}
.columns #container {
width: 100%; /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */
height: 100%;
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
text-align: left; /* this overrides the text-align: center on the body element. */
}
.columns #header {
background: #000000;
background-image: url(header_bg.jpg);
background-attachment: fixed;
background-repeat: no-repeat;
padding: 1% 18% 1% 18%;
height: 70px;
}
.columns #header h1 {
margin: 0;
padding: 10px 0;
color: #FFFFFF;
font-size: 40px;
}
.columns #lheader {
padding-top: 1%;
padding-bottom: 1%;
margin: 0;
width: 308px;
float:left;
text-align: right;
}
.columns #rheader {
padding-top: 1%;
padding-bottom: 1%;
margin: 0;
width: auto;
float:right;
height: 70px;
text-align: right;
}
.columns #rheader a:link, a:visited, a:active {
font-size: 13px;
padding: 5px;
font-weight: bold;
color: #999999;
text-decoration:none;
}
.columns #rheader a:hover {
text-decoration:none;
padding:5px;
color: #FFFFFF;
background-color: #666666;
-moz-border-radius: 4px;
}
.columns #feature {
background:#A5F900;
background-image: url(feature.jpg);
height: auto;
padding: 1% 18% 1% 18%;
}
.columns #feature p{
color: #FFFFFF;
font-weight: bold;
font-size: 15px;
margin: 0;
padding: 10px 0px;
}
.columns #mainContent {
padding: 1% 18% 1% 18%;
background-image: url(content_bg.jpg);
vertical-align:top;
background-attachment: fixed;
background-repeat: no-repeat;
background: #FFFFFF;
height: auto;
}
.columns #footer {
padding: 0 18% 0 18%;
background-image: url(footer_bg.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
font-size:12px;
height: auto;
line-height: 20px;
color: #999999;
}
.columns #lfooter {
padding-top: 1%;
padding-bottom: 1%;
background-color: transparent;
margin: 0;
width: 70%;
float: left;
}
.columns #rfooter {
padding-top: 1%;
padding-bottom: 1%;
background-color: transparent;
margin: 0;
width: 30%;
float: left;
text-align: right;
}
.columns #footer a:link, a:visited, a:active {
text-decoration:none;
color: #999999;
}
.columns #footer a:hover {
text-decoration:none;
color: #FFFFFF;
}




HTML


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Same Choice Printing Products | Hong Kong</title>
<link href="oneColElsCtrHdr.css" rel="stylesheet" type="text/css" />
</head>

<body class="columns">

<div id="container">
<div id="topborder"></div>
<div id="header">
<div id="lheader">
<img src="logo_text.png" alt="Same Choice">
</div>
<div id="rheader">
<p>
<a href="index.html">Home</a>&nbsp;&nbsp;
<a href="about.html">About Us</a>&nbsp;&nbsp;
<a href="products.html">Our Products</a>&nbsp;&nbsp;
<a href="contact.html">Contact Us</a>
</p>
</div>
</div>
<div id="feature">
<p>images images images, featured abstract</p>

</div>
<div id="mainContent">
<h1> Main Content </h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio. Donec et ipsum et sapien vehicula nonummy. Suspendisse potenti. Fusce varius urna id quam. Sed neque mi, varius eget, tincidunt nec, suscipit id, libero. In eget purus. Vestibulum ut nisl. Donec eu mi sed turpis feugiat feugiat. Integer turpis arcu, pellentesque eget, cursus et, fermentum ut, sapien. Fusce metus mi, eleifend sollicitudin, molestie id, varius et, nibh. Donec nec libero.</p>
<h2>H2 level heading </h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>
</div>
<div id="footer">
<div id="lfooter">
<p>
<a href="index.html" alt="Home">Home</a> |
<a href="about.html" alt="About Us">About Us</a> |
<a href="products.html" alt="OEM">Our Products</a> |
<a href="contact.html" alt="Contact Us"> Contact Us</a><br>
&copy; Same Choice Printing Products Co. Ltd
</p>
</div>
<div id="rfooter">
<p>
(852) 2950 1388<br>
<a href="contact.html" alt="Contact Us">enquiry@samechoice.com</a>
</p>
</div>
</div>
</div>
</body>
</html>

medigerati
01-26-2008, 06:35 PM
Because the two divs inside the footer are floated, the footer div won't have a height. Either float the footer also, or add a clearfix.

http://www.456bereastreet.com/archive/200603/new_clearing_method_needed_for_ie7/

effpeetee
01-26-2008, 06:35 PM
The assembled code for anyone interested. Frank:D

Also here: http://www.exitfegs.co.uk/atest.html



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Same Choice Printing Products | Hong Kong</title>
<style type="text/css">

@charset "UTF-8";
body {
font: 100&#37; Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}

/* Tips for Elastic layouts
1. Since the elastic layouts overall sizing is based on the user's default fonts size, they are more unpredictable. Used correctly, they are also more accessible for those that need larger fonts size since the line length remains proportionate.
2. Sizing of divs in this layout are based on the 100% font size in the body element. If you decrease the text size overall by using a font-size: 80% on the body element or the #container, remember that the entire layout will downsize proportionately. You may want to increase the widths of the various divs to compensate for this.
3. If font sizing is changed in differing amounts on each div instead of on the overall design (ie: #sidebar1 is given a 70% font size and #mainContent is given an 85% font size), this will proportionately change each of the divs overall size. You may want to adjust based on your final font sizing.
*/
.columns #topborder {
width: 100%; /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */
height: 5px;
background: #0099FF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
text-align: left; /* this overrides the text-align: center on the body element. */
}
.columns #container {
width: 100%; /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */
height: 100%;
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
text-align: left; /* this overrides the text-align: center on the body element. */
}
.columns #header {
background: #000000;
background-image: url(header_bg.jpg);
background-attachment: fixed;
background-repeat: no-repeat;
padding: 1% 18% 1% 18%;
height: 70px;
}
.columns #header h1 {
margin: 0;
padding: 10px 0;
color: #FFFFFF;
font-size: 40px;
}
.columns #lheader {
padding-top: 1%;
padding-bottom: 1%;
margin: 0;
width: 308px;
float:left;
text-align: right;
}
.columns #rheader {
padding-top: 1%;
padding-bottom: 1%;
margin: 0;
width: auto;
float:right;
height: 70px;
text-align: right;
}
.columns #rheader a:link, a:visited, a:active {
font-size: 13px;
padding: 5px;
font-weight: bold;
color: #999999;
text-decoration:none;
}
.columns #rheader a:hover {
text-decoration:none;
padding:5px;
color: #FFFFFF;
background-color: #666666;
-moz-border-radius: 4px;
}
.columns #feature {
background:#A5F900;
background-image: url(feature.jpg);
height: auto;
padding: 1% 18% 1% 18%;
}
.columns #feature p{
color: #FFFFFF;
font-weight: bold;
font-size: 15px;
margin: 0;
padding: 10px 0px;
}
.columns #mainContent {
padding: 1% 18% 1% 18%;
background-image: url(content_bg.jpg);
vertical-align:top;
background-attachment: fixed;
background-repeat: no-repeat;
background: #FFFFFF;
height: auto;
}
.columns #footer {
padding: 0 18% 0 18%;
background-image: url(footer_bg.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
font-size:12px;
height: auto;
line-height: 20px;
color: #999999;
}
.columns #lfooter {
padding-top: 1%;
padding-bottom: 1%;
background-color: transparent;
margin: 0;
width: 70%;
float: left;
}
.columns #rfooter {
padding-top: 1%;
padding-bottom: 1%;
background-color: transparent;
margin: 0;
width: 30%;
float: left;
text-align: right;
}
.columns #footer a:link, a:visited, a:active {
text-decoration:none;
color: #999999;
}
.columns #footer a:hover {
text-decoration:none;
color: #FFFFFF;
}
</style>
</head>

<body class="columns">

<div id="container">
<div id="topborder"></div>
<div id="header">
<div id="lheader">
<img src="logo_text.png" alt="Same Choice">
</div>
<div id="rheader">
<p>
<a href="index.html">Home</a>&nbsp;&nbsp;
<a href="about.html">About Us</a>&nbsp;&nbsp;
<a href="products.html">Our Products</a>&nbsp;&nbsp;
<a href="contact.html">Contact Us</a>
</p>
</div>
</div>
<div id="feature">
<p>images images images, featured abstract</p>

</div>
<div id="mainContent">
<h1> Main Content </h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio. Donec et ipsum et sapien vehicula nonummy. Suspendisse potenti. Fusce varius urna id quam. Sed neque mi, varius eget, tincidunt nec, suscipit id, libero. In eget purus. Vestibulum ut nisl. Donec eu mi sed turpis feugiat feugiat. Integer turpis arcu, pellentesque eget, cursus et, fermentum ut, sapien. Fusce metus mi, eleifend sollicitudin, molestie id, varius et, nibh. Donec nec libero.</p>
<h2>H2 level heading </h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>
</div>
<div id="footer">
<div id="lfooter">
<p>
<a href="index.html" alt="Home">Home</a> |
<a href="about.html" alt="About Us">About Us</a> |
<a href="products.html" alt="OEM">Our Products</a> |
<a href="contact.html" alt="Contact Us"> Contact Us</a><br>
&copy; Same Choice Printing Products Co. Ltd
</p>
</div>
<div id="rfooter">
<p>
(852) 2950 1388<br>
<a href="contact.html" alt="Contact Us">enquiry@samechoice.com</a>
</p>
</div>
</div>
</div>
</body>
</html>>

stefonia
01-28-2008, 12:57 PM
thanks the clearfix did work for the footer.
i added the same clearfix property together with display:inline-block to the DIV container mainContents and display:block to the two floats inside the container, but the container did not expand to wrap the floats inside it. any suggestions?

again, thanks in advance!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum