html - Multi boxs css hover -
i want make box pack includes 5 below. when leaving mouse on box, box extend whole main div , display of rest of boxes set none. in code, box1's mouse hover extend.
these codes.
.multibox{ width: 300px; height: 300px; border: 1px solid black; overflow: hidden; } .multibox div{ position: absolute; transition: width 0.5s, height 0.5s, -webkit-transform 0.5s; -moz-transition: width 0.5s, height 0.5s, -webkit-transform 0.5s; /* firefox 4 */ -webkit-transition: width 0.5s, height 0.5s, -webkit-transform 0.5s; /* safari , chrome */ -o-transition: width 0.5s, height 0.5s, -webkit-transform 0.5s; /* opera */ -ms-transition: width 0.5s, height 0.5s, -webkit-transform 0.5s; /* ie9 (maybe) */ } .box1{ background: gray; width: 250px; height: 50px; float: right; display: block; position: initial !important; } .box1:hover{ width: 300px; height: 300px; } .box2{ background: blue; width: 50px; height: 250px; float: left; display: block; position: initial !important; } .box2:hover{ width: 300px; height: 300px; } .box3{ background: red; width: 50px; height: 250px; display: block; float: right; position: initial !important; } .box3:hover{ width: 300px; height: 300px; } .box4{ background: green; width: 200px; height: 200px; display: block; float: right; position: initial !important; } .box4:hover{ width: 300px; height: 300px; } .box5 { background: brown; width: 250px; height: 50px; display: block; float: left; position: initial !important; } .box5:hover{ width:300px; height: 300px; }
<html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"/> </head> <body> <div class="multibox"> <div class="box1"> box 1 </div> <div class="box2"> box 2 </div> <div class="box3"> box 3 </div> <div class="box4"> box 4 </div> <div class="box5"> box 5 </div> </div> </body> </html>
in part have made mistake?
make boxes position:absolute
, place them properly.
.multibox{ width: 300px; height: 300px; border: 1px solid black; overflow: hidden; position: relative; } .multibox div{ position: absolute; transition: 0.5s, height 0.5s, -webkit-transform 0.5s; -moz-transition: 0.5s, height 0.5s, -webkit-transform 0.5s; /* firefox 4 */ -webkit-transition: 0.5s, height 0.5s, -webkit-transform 0.5s; /* safari , chrome */ -o-transition: 0.5s, height 0.5s, -webkit-transform 0.5s; /* opera */ -ms-transition: 0.5s, height 0.5s, -webkit-transform 0.5s; /* ie9 (maybe) */ } .multibox div:hover{ z-index: 99; } .box1{ background: gray; width: 250px; height: 50px; right: 0; top: 0; display: block; } .box1:hover{ width: 300px; height: 300px; } .box2{ background: blue; width: 50px; height: 250px; float: left; display: block; } .box2:hover{ width: 300px; height: 300px; } .box3{ background: red; width: 50px; height: 250px; display: block; right: 0; top: 50px; } .box3:hover{ width: 300px; height: 300px; top: 0; } .box4{ background: green; width: 200px; height: 200px; display: block; left: 50px; top: 50px; } .box4:hover{ width: 300px; height: 300px; left: 0; top: 0; } .box5 { background: brown; width: 250px; height: 50px; display: block; left: 0; bottom: 0; } .box5:hover{ width:300px; height: 300px; }
<div class="multibox"> <div class="box1"> box 1 </div> <div class="box2"> box 2 </div> <div class="box3"> box 3 </div> <div class="box4"> box 4 </div> <div class="box5"> box 5 </div> </div>
Comments
Post a Comment