Visibility & Z-index
<!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;
}
#box1{
position: relative;
top: 49px;
z-index: 35;
background-color: green;
}
#box2{
position: relative;
top: 14px;
/* z-index: will work only for position: relative, absolute, fixed or sticky */
z-index: 34;
/* (will hide the element and space) */
/* display: none; */
/* (will hide the element will but show empty space) */
/* visibility: hidden; */
background-color: rgb(128, 10, 49);
}
#box3{background-color: rgb(25, 7, 92);}
#box4{background-color: rgb(251, 255, 6);}
</style>
</head>
<body>
<div class="box" id="box1"></div>
<div class="box" id="box2"></div>
<div class="box" id="box3"></div>
<div class="box" id="box4"></div>
</body>
</html>
Comments
Post a Comment