HTML Dog
Skip to navigation

Z-index

Stacking positioned boxes.

HTML

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Z-index</title>
	<style>
		body {
			font: 14px courier;
			background: #c72 url("/examples/images/opacityBg.gif");
			color: #000;
			padding: 0;
		}
	
		p {
			position: absolute;
			width: 400px;
			height: 200px;
			background: white;
			border: 1px solid #ccc;
			box-shadow: 0 0 10px #999;
			margin: 0;
		}
		code {
			padding: 0 15px;
		}

		.p1 {
			top: 80px;
			left: 80px;
			z-index: 4;
		}
		.p2 {
			top: 60px;
			left: 60px;
			z-index: 3;
		}
		.p3 {
			top: 40px;
			left: 40px;
			z-index: 2;
		}
		.p4 {
			top: 20px;
			left: 20px;
			z-index: 1;
		}
		p:hover {
			z-index: 6;
		}
		
		#borderCollie {
			top: 100px;
			left: 100px;
			z-index: 5;
		}
		#borderCollie a {
			display: block;
			width: 120px;
			height: 90px;
			padding: 55px 140px;
		}
	</style>
</head>
<body>
	<p class="p1"><code>z-index: 4;</code></p>
	<p class="p2"><code>z-index: 3;</code></p>
	<p class="p3"><code>z-index: 2;</code></p>
	<p class="p4"><code>z-index: 1;</code></p>

	<!-- Link back to HTML Dog: -->
	<p id="borderCollie"><a href="http://www.htmldog.com/examples/"><img src="http://www.htmldog.com/badge1.gif" alt="HTML Dog"></a></p>
</body>
</html>

Output

View original