martynball
01-26-2012, 11:26 PM
Hey, i'm having a bit of an issue with getting the background image of the "image_container" div to show... Basically this website it to have two images, one in the background of a div, and one an image with a div infront of that so text and content can be added.
Need the two images so that the front one can be faded out, then switched to another one. Then it will fade back in after afew seconds. The background picture of the div will then change.. this loops.
I could also to with a better way to center the entire container instead of using percentages as they do not work very good.
http://i58.photobucket.com/albums/g268/martynball/background_image_no_work.jpg
<!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>Discount Koi</title>
<style type="text/css">
body {
background-color:#2b2b2b;
background-image: url(images/background_gradient.jpg);
background-repeat:no-repeat;
background-size:60%;
}
.main_content_container {
position:absolute;
width:810px;
height:500px;
margin:2% 15%;
}
.main_content {
background-color:#003366;
}
.social_icons { text-align:right; margin-bottom:4px; }
.icon {
background-image:url(images/social_icons.png);
height:27px; width:27px;
display:inline-block;
} .icon img { visibility:hidden; }
.twitter { background-position:0px 0px; } .twitter:hover { background-position:0px -27px; }
.rrs { background-position:27px 0px; } .rrs:hover { background-position:27px -27px; }
.facebook { background-position:54px 0px; } .facebook:hover { background-position:54px -27px; }
.content_container {
background-size:100%;
background-repeat:no-repeat;
position:absolute;
}
.shadow {
position:absolute;
bottom:;
margin-top:110%%;
}
.content_container {
width:100%; height:100%;
position:absolute;
}
.image_container img {
position:absolute;
}
.image_container {
background-image:url(images/backgrounds/hamster.jpg);
}
h1 {
font-family:Trebuchet MS;
font-weight:100;
color:#FFFFFF;
font-size:28px;
margin:20px;
padding-left:20px;
background-repeat:no-repeat;
background-image:url(images/header_side.gif);
}
</style>
<script type="text/javascript">
//This function fades images in and out for the home page. Make sure it is activated again when page is reloaded using AJAX.
function bg_fader() {
//Elements to swap images with
var elm1 = "image1";
var elm2 = "image_container";
//document.getElementById(elm2).style.backgroundImage="";
}
</script>
</head>
<body>
<div class="container">
<div class="main_content_container">
<div class="social_icons">
<a href="#"><div class="icon twitter"><img src="images/icon_buffer.gif"></div></a>
<a href="#"><div class="icon facebook"><img src="images/icon_buffer.gif"></div></a>
<a href="#"><div class="icon rrs"><img src="images/icon_buffer.gif"></div></a>
</div>
<div class="image_container">
<!--<img src="images/backgrounds/snake.jpg" width="810px" id="image1" />-->
<div class="content_container" id="image2">
<h1>Discount Koi & <br />Aquatics</h1>
</div>
</div>
<img src="images/background_shadow.jpg" width="100%" class="shadow" />
</div>
</div>
</body>
</html>
Need the two images so that the front one can be faded out, then switched to another one. Then it will fade back in after afew seconds. The background picture of the div will then change.. this loops.
I could also to with a better way to center the entire container instead of using percentages as they do not work very good.
http://i58.photobucket.com/albums/g268/martynball/background_image_no_work.jpg
<!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>Discount Koi</title>
<style type="text/css">
body {
background-color:#2b2b2b;
background-image: url(images/background_gradient.jpg);
background-repeat:no-repeat;
background-size:60%;
}
.main_content_container {
position:absolute;
width:810px;
height:500px;
margin:2% 15%;
}
.main_content {
background-color:#003366;
}
.social_icons { text-align:right; margin-bottom:4px; }
.icon {
background-image:url(images/social_icons.png);
height:27px; width:27px;
display:inline-block;
} .icon img { visibility:hidden; }
.twitter { background-position:0px 0px; } .twitter:hover { background-position:0px -27px; }
.rrs { background-position:27px 0px; } .rrs:hover { background-position:27px -27px; }
.facebook { background-position:54px 0px; } .facebook:hover { background-position:54px -27px; }
.content_container {
background-size:100%;
background-repeat:no-repeat;
position:absolute;
}
.shadow {
position:absolute;
bottom:;
margin-top:110%%;
}
.content_container {
width:100%; height:100%;
position:absolute;
}
.image_container img {
position:absolute;
}
.image_container {
background-image:url(images/backgrounds/hamster.jpg);
}
h1 {
font-family:Trebuchet MS;
font-weight:100;
color:#FFFFFF;
font-size:28px;
margin:20px;
padding-left:20px;
background-repeat:no-repeat;
background-image:url(images/header_side.gif);
}
</style>
<script type="text/javascript">
//This function fades images in and out for the home page. Make sure it is activated again when page is reloaded using AJAX.
function bg_fader() {
//Elements to swap images with
var elm1 = "image1";
var elm2 = "image_container";
//document.getElementById(elm2).style.backgroundImage="";
}
</script>
</head>
<body>
<div class="container">
<div class="main_content_container">
<div class="social_icons">
<a href="#"><div class="icon twitter"><img src="images/icon_buffer.gif"></div></a>
<a href="#"><div class="icon facebook"><img src="images/icon_buffer.gif"></div></a>
<a href="#"><div class="icon rrs"><img src="images/icon_buffer.gif"></div></a>
</div>
<div class="image_container">
<!--<img src="images/backgrounds/snake.jpg" width="810px" id="image1" />-->
<div class="content_container" id="image2">
<h1>Discount Koi & <br />Aquatics</h1>
</div>
</div>
<img src="images/background_shadow.jpg" width="100%" class="shadow" />
</div>
</div>
</body>
</html>