Click here to Skip to main content
Click here to Skip to main content

Show Image over an Image using CSS

, 25 Nov 2011
Rate this:
Please Sign up or sign in to vote.
Show Image over an Image using CSS

Description

This Tip/Trick shows how to show an image over another image. Using the properties position, left, top, z-index, you can achieve that.

Code

<html>
<head>
<title>Show Image over image</title>
<style type="text/css"> 
img { position:absolute; top: 25px; z-index: 2;}
.imgA1 { left: 0px; } 
.imgB1 { left: 0px; } 
.imgB2 { left: 15px; } 
.imgB3 { left: 30px; } 
.imgB4 { left: 45px; } 
.imgB5 { left: 60px; } 
.imgB6 { left: 75px; } 
.imgB7 { left: 90px; } 
.imgB8 { left: 105px; } 
.imgB9 { left: 120px; } 
</style>
</head>
<body>
<img src="http://www.codeproject.com/Info/images/codeproject125x125.gif" style="z-index: 1;" class="imgA1"/>
<img src="line.gif" class="imgB1" />
<img src="line.gif" class="imgB2" />
<img src="line.gif" class="imgB3" />
<img src="line.gif" class="imgB4" />
<img src="line.gif" class="imgB5" />
<img src="line.gif" class="imgB6" />
<img src="line.gif" class="imgB7" />
<img src="line.gif" class="imgB8" />
<img src="line.gif" class="imgB9" />
</body>
</html>

Browser Compatibility

I have tested this script in the following Web browsers:
  • Internet Explorer
  • Mozilla Firefox
  • Google Chrome
  • Safari
  • Opera

Result

This sample code will show you our Bob Green Alien | [Alien] in Prison.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

thatraja
Web Developer
India India
Programmer | Dude | ||||||
 
About him & his blog? check out here. Currently he's updating the site, he'll return soon there with more things*.
 
In Codeproject, he posted a blogpost & more than couple of Tip/Tricks, hope he'll write more soon.
 
Favorite techs are MVC, WCF, Mobile, HTML5, CSS3, jQuery, etc.,
 
His hobbies are watching movies, CP, being alone, etc., But now he's working on something*.
 
* - SCAMP???
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
GeneralRe: No The reason was not Hiren. Even he helped me once when I d... PinmemberShilpi Boosar10-Mar-11 0:02 
GeneralRe: Oops, I have noticed that later. Actually that site saved th... Pinmvpthatraja10-Mar-11 6:17 
Oops, I have noticed that later. Actually that site saved that file in that name.Unfortunately I can't upload pictures in CP because I'm still not a Platinum author *sigh* , But one day I'll.Smile | :)
BTW welcome
GeneralRe: Why you are not visiting GIT? Dont worry Hiren is not visiti... PinmemberSChristmas9-Mar-11 21:54 
GeneralRe: Done ... The spelling of line was linet.gif and in HTML it i... PinmemberShilpi Boosar9-Mar-11 18:58 
GeneralRe: It display the bob but line image is not displayed. Path of ... PinmemberShilpi Boosar9-Mar-11 18:56 
GeneralReason for my vote of 5 Neat, my 5 PinmvpEspen Harlinn17-Jul-11 23:53 
GeneralReason for my vote of 5 Nice Idea :) PinmvpRaviRanjankr10-Mar-11 17:08 
GeneralReason for my vote of 5 Great concept buddy PinmemberSChristmas9-Mar-11 21:48 
GeneralReason for my vote of 5 Nice one Raja. PinmemberE$w@r9-Mar-11 21:28 
GeneralSilly question but how do i achieve it ??? I was not workin... PinmemberShilpi Boosar9-Mar-11 18:19 
GeneralRe: Just copy & paste the HTML & save as a html file. Also the d... Pinmvpthatraja9-Mar-11 18:45 
GeneralDude, Your HTML is not perfect. You haven't closed Bob's IMG... PinmemberVenkatesh Mookkan9-Mar-11 17:49 
GeneralRe: Yeah, but it's in 2nd revision. I can't fix that. Waiting fo... Pinmvpthatraja9-Mar-11 18:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 25 Nov 2011
Article Copyright 2011 by thatraja
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid