<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Visibility and z-index</title>
<style>
.box {
width: 170px;
height: 170px;
border: 2px solid black;
}
#box-1 {
position: relative;
top: 49px;
z-index: -35;
background-color: green;
}
#box-2 {
position: relative;
top: 14px;
z-index: 35;
/* z-index: will work only for position: relative, absolute, fixed or sticky; */
/* will hide the element and the space */
/* display: none;
/* will hide the element but will show its empty space */
/* /* visibility: hidden; */
background-color: red
}
#box-3 {
background-color: blue;
}
#box-4 {
background-color: yellow;
}
</style>
</head>
<body>
<div class="box" id="box-1"></div>
<div class="box" id="box-2"></div>
<div class="box" id="box-3"></div>
<div class="box" id="box-4"></div>
</body>
</html>
No comments:
Post a Comment