I am trying to add a transition effect to an element on my website. This element is set to display:none, but is set to display:block when a checkbox is clicked (the checkbox is a separate element). What i want to do is make it so that when the checkbox is checked, the element gets set to display:block, and also shows a transition, instead of it popping up. Here is my code:
.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>