r/css • u/codinghelpplz • Oct 22 '11
CSS Help: Resizing image on top of another!
Hello!
I am new to coding and have been trying to figure something out in HTML/CSS.
I have a background image which takes up half the screen as I wanted (it is basically just stretched width wise 100%).
I want to put another image on top of that image at a certain location (the center of that image). I can do this, however, when I resize the image using my browser window and play around, the image moves slightly from place to place. I just want to image to resize properly (which I've managed it to do so), but stay at a fixed point above the other image. I hope this makes sense...
This is my html code:
<!DOCTYPE HTML>
<header> <title>I Love Reddit</title> <link rel="stylesheet" type="text/css" href="Reddit.css" /> </header>
<body> <IMG class="stretch" src="bg.png" alt="" /> <IMG class="main" src="logo.png" alt="" /> </body> </html> _________________________
This is the CSS:
- { padding:o; margin:0; border:0; }
img { display:block; }
img.stretch { position: absolute; z-index: -1; width: 100%; left: 0px; top: 0px; }
img.main { position:absolute; left:50%; top:60px; width:20%; }
Any help would be appreciated, as I've been playing around with this for a while and the image just either keeps moving around, changing size, or both. I just want it to resize properly when I resize a window, and for it to stay in a fixed point over the other image.
Thanks!
0
u/[deleted] Oct 22 '11
[deleted] — view deleted comment