【发布时间】:2020-01-14 14:50:35
【问题描述】:
我使用 HTML 创建了一张卡片。文本类 div 仅在文本类 div 悬停时出现。如何更改 HTML 和 CSS 以便在父 div 悬停时出现文本 div。
.bg {
background-color: white;
width: 200px;
height: 300px;
border: solid red 2px;
overflow: hidden;
}
.text {
background-color: gray;
position: relative;
top: 180px;
transition: top 0.5s;
}
.text:hover {
top: 132px
}
<div class="bg">
<div class="text">
<h3>Test text</h3>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Reiciendis voluptas pariatur qui aut animi molestiae quia veritatis culpa excepturi. Nesciunt optio ipsa molest</p>
</div>
</div>
【问题讨论】:
-
是的,制定规则
.bg:hover .text { top: 132px }
标签: html css transition