By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,676 Members | 1,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,676 IT Pros & Developers. It's quick & easy.

Image tag with CSS background attribute

P: 18
Hi, I've got an Image (a transparent png) over a background (a jpeg).
I'd like them to stretch toghether.
I've tried:
<img src="MyImage.png" alt"foreground image" width"100%" height"100%"
style"
background-image: url(MyBackground.jpeg);
background-repeat: no-repeat;
background-size: 100%;" />

Doing so I can correctly see the png over the jpeg, but when I resize the window I got the png stretched while the background jpeg doesn't move.
Why doesn't it work?
Feb 5 '08 #1
Share this Question
Share on Google+
1 Reply


Death Slaught
100+
P: 1,137
Your background image won't stretch because it is 'part' of the page itself so to speak. It can't be resized because you would have to increase the size of the browser itself (which isn't possible).

You can put two images in the same 'container' and give one of them a z-index

^_^ Thanks, Death
Feb 5 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.