Last active
November 22, 2018 07:15
-
-
Save liketaurus/8108fe165960fb93730ed9346bee03ef to your computer and use it in GitHub Desktop.
How to place one div on top of another - 'position' and 'z-order' game (based on jsbin.com/edejus/1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Div on Div</title> | |
<style> | |
#box { | |
width: 428px; | |
height: 200px; | |
position: relative; | |
} | |
#onTop { | |
width: 100%; | |
height: 100%; | |
position: absolute; | |
top: 50px; | |
left: 150px; | |
z-index: 10; | |
} | |
#onBack { | |
width: 100%; | |
height: 100%; | |
position: absolute; | |
top: 0px; | |
left: 80px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="box"> | |
<div id="onTop"> | |
<img src="https://www.w3.org/html/logo/downloads/HTML5_Logo_128.png" /> | |
</div> | |
<div id="onBack"> | |
<img src="http://resumbrae.com/ub/dms423_f08/22/cloudsTexture.jpg" /> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment