我正在尝试为网站上的一个元素添加过渡效果。这个元素被设置为 display:none,但当复选框被点击时(复选框是一个单独的元素),它被设置为 display:block。我想做的是,当复选框被选中时,将元素设置为 display:block,并显示一个过渡效果,而不是弹出来。以下是我的代码:
.category-text {
width: 82%;
padding-top: 5px;
padding-left: 8px;
font-family: 'Burbank', sans-serif;
font-size: 30px;
color: #F4D03F;
}
.desc-toggle {
position: absolute;
top: 5px;
left: 84.4%;
width: 73px;
padding: 5px;
font-family: 'Burbank', sans-serif;
font-size: 20px;
color: blue;
cursor: pointer;
z-index: 2;
border: solid #ffffff 2px;
}
#toggle-1 {
display: none;
}
input[type=checkbox]:checked ~ .category-description {
position: absolute;
display: block;
-webkit-transition: height 0.5s ease-in;
-moz-transition: height 0.5s ease-in;
-ms-transition: height 0.5s ease-in;
-o-transition: height 0.5s ease-in;
transition: height 0.5s ease-in;
}
<label class="desc-toggle" for="toggle-1">Description</label>
<input type="checkbox" id="toggle-1">
<div class="category-description">
<p class="category-text">text</p>
</div>
display: none
? - Hydrothermal