將高度設(shè)置為0 并隱藏滾動(dòng)條 適合動(dòng)畫(huà)效果
.box2 {
width: 100px;
height: 0;
overflow: hidden;
transition: height 0.3s,background-color 0.3s; //動(dòng)畫(huà)效果
}
.box1:hover .box2 {
height: 100px;
width: 100px;
background: red;
}
隱藏像素不占位置
//隱藏元素 不占位置
.box1 {
width:100px;
height:100px;
background:red;
display:none;
}
占據(jù)位置的隱藏元素
.box2 {
height: 100px;
width: 100px;
background: red;
visibility: hidden;
}