Jaron787 Jaron787 - 7 months ago 7
HTML Question

HTML CSS - Placing one image on top of another

I want to place one image on top of another whilst keeping the contents underneath from being shifted up. I know you can use absolute positioning but this shifts everything below behind the image as well. Does anyone know how to achieve this?

I have the below example which I need editing to place the circle on top of the square:

https://jsfiddle.net/Jaron787/2mv98mkp/2/

HTML

<div>
<img src='http://www.clker.com/cliparts/U/D/B/J/j/R/red-square-th.png'>
<img src='http://www.clker.com/cliparts/G/f/E/Y/v/l/circle-th.png'>
</div>
<div id="lse" class="display">
<div id="centertbl">
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 1</b></td>
</tr>
</table>

<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 2</b></td>
</tr>
</table>
</div>

<input type="submit" class="button button1" name="submitButton" value="Button 1">
<input type="submit" class="button button1" name="submitButton" value="Button 2">
<input type="submit" class="button button1" name="submitButton" value="Button 3">
<input type="submit" class="button button1" name="submitButton" value="Button 4">

</div>


CSS

.TSS {
border: 1px solid #000000;
float: none;
font-family: Verdana, Geneva, sans-serif;
font-size: 10.6px;
font-style: normal;
padding: 10px;
text-decoration: none;
display: inline-block;
}

#centertbl {
text-align: center;
}

.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 0.4s;
cursor: pointer;
}

.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}

.button1:hover {
background-color: #4CAF50;
color: white;
}

Answer

Add the following css to the circle:

#circle{
 position:relative;
 z-index:1;
left:-100px;
}

Edited the fiddle: https://jsfiddle.net/Debabrata89/qdd2z402/

Comments