tqmd1
11-09-2011, 07:34 AM
Dear Sir,
I have following codes
<html> <style type="text/css"> #d1 {float:left; width:200px;height:200px; background-color:e3eeff; margin:20px 20px 20px 20px; padding:20px 20px 20px 20px; text-align:center; vertical-align:middle; letter-spacing:10pt;} .bg {width:100%;height:100%;position:absolute;z-index:-1;} </style> <body> <div id="d1"><img class="bg" src="dream.jpg" width=100 height=100%><h2>Hello world</h2></div> </body> </html><html>
<style type="text/css">
#d1 {float:left;
width:200px;height:200px;
background-color:e3eeff;
margin:20px 20px 20px 20px;
padding:20px 20px 20px 20px;
text-align:center;
vertical-align:middle;
letter-spacing:10pt;}
.bg {width:100%;height:100%;position:absolute;z-index:-1;}
</style>
<body>
<div id="d1"><img class="bg" src="dream.jpg" width=100 height=100%><h2>Hello world</h2></div>
</body>
</html>
I want to know
Why background image goes outside of div?
I want result shown in attached file
Please help
I have following codes
<html> <style type="text/css"> #d1 {float:left; width:200px;height:200px; background-color:e3eeff; margin:20px 20px 20px 20px; padding:20px 20px 20px 20px; text-align:center; vertical-align:middle; letter-spacing:10pt;} .bg {width:100%;height:100%;position:absolute;z-index:-1;} </style> <body> <div id="d1"><img class="bg" src="dream.jpg" width=100 height=100%><h2>Hello world</h2></div> </body> </html><html>
<style type="text/css">
#d1 {float:left;
width:200px;height:200px;
background-color:e3eeff;
margin:20px 20px 20px 20px;
padding:20px 20px 20px 20px;
text-align:center;
vertical-align:middle;
letter-spacing:10pt;}
.bg {width:100%;height:100%;position:absolute;z-index:-1;}
</style>
<body>
<div id="d1"><img class="bg" src="dream.jpg" width=100 height=100%><h2>Hello world</h2></div>
</body>
</html>
I want to know
Why background image goes outside of div?
I want result shown in attached file
Please help