css - How to set a background image in full size of a div that doesn't fill page -
i need put image in background of div @ center position of it, like:
what i've tried is:
<div id="container"> ... </div <div id="background"> <img src="images/bg.png"/> </div>
with css:
div#container { margin: 0 auto; width: 52em; } div#bg img { z-index: -999; width: 100%; height: 100%; position: absolute; top: 22%; }
in browser, screen size, put 22% , ok, if try on screen different size background img isn't in center of div. can do? can someonehelp me?
give
position:relative;
in container div..it should work.. , background div(with position:absolute;
) should child of container div..then u'll div overlapping property
Comments
Post a Comment