As the title says, how do you add an image over an image using html or css?
[HTML/CSS]How do you add an image over an image? |
|
You could use divs.
For example: Code <div class="image1">Code .image1 {
Dec 3, 2013 07:52 AM
(This post was last modified: Dec 3, 2013 07:52 AM by ~Dec.)
CSS3 allows multiple background images as well, using this syntax (left-most image = top-most image):
Code .selector {
I would go with z-index too
Probably the best way of doing it http://css-tricks.com/almanac/properties/z/z-index/ (Dec 4, 2013 06:14 AM)resent Wrote: To use z-index, the images already have to be positioned over each other. [img]http://asterisk.apod.com/images/smilies/facepalm.gif[/img] You can give it whatever position you want to, (not static ofc.), and then z-index will work, so why don't you got somewhere else with that ugly smiley? (Dec 4, 2013 08:09 AM)iDyxl Wrote: You can give it whatever position you want to, (not static ofc.), and then z-index will work, so why don't you got somewhere else with that ugly smiley? z-index makes no difference and actually is the worst possible way to do it. What if you have #image1 and #image2, and you use position:absolute and z-index to lay #image2 over #image1. Then you want that when the user hovers over #image1, #image2 will change colour... Because of the z-index, #image1's mouse events won't occur because the mouse never passes over it since it's behind something else... Honestly, CSS3 multiple background images were created just for this purpose. You can also use pseudo-elements, or simply just wrap one image in another one using divs... |
|
|



![[Image: 2QzRqrh.png]](https://i.imgur.com/2QzRqrh.png)