Skip to content

Instantly share code, notes, and snippets.

@liketaurus
Last active November 22, 2018 07:15
Show Gist options
  • Save liketaurus/8108fe165960fb93730ed9346bee03ef to your computer and use it in GitHub Desktop.
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)
<!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