html - 如何将转换延迟添加到相邻的兄弟选择器(仅限 CSS)
问题描述
我有一个显示为“无”的 div。我希望在我将鼠标悬停在其兄弟元素上 1 秒后显示此 div> 我目前正在 CSS 中使用 transition-delay 属性,但在使用相邻兄弟选择器时它似乎不起作用。这是我当前的代码:
HTML
<i id="pass" style="font-size: 30px; width: 50px" class="fa fa-users fa-3" aria-hidden="true"></i>
<div class="speech-bubble" id="pass_hover">
<h1>2+ Passenger Seating</h1>
</div>
CSS
.speech-bubble {
display: none;
}
#pass:hover + #pass_hover {
transition-delay:1s;
display: block;
}
解决方案
尝试这样的事情
<i id="pass" style="font-size: 30px; width: 50px" class="fa fa-users fa-3" aria-hidden="true"></i>
<div class="speech-bubble" id="pass_hover">
<h1>2+ Passenger Seating</h1>
</div>
.speech-bubble:after {
height :0;
}
#pass + #pass_hover {
transition: all 1s;
transition-delay:.1s;
height: 0;
width: 0;
opacity:0;
}
#pass:hover + #pass_hover {
transition-delay:.1s;
display: block;
height: 100%;
width:100%;
opacity : 1;
}
推荐阅读
- c# - 在子目录中加载 Microsoft.ReportViewer.WebForms 的问题
- java - 为什么 setContentView(R.layout.activity_main) 和 findViewById(R.id.example) 不使用点符号来引用对象?
- spring - 同一测试中的不同控制器
- arrays - 遍历非连续列
- javascript - 使用 NodeJS 读取 PDF 并在客户端呈现上下文
- mysql - 选择和使用两个表(更详细的解释在帖子中)
- excel - Excel - 如何获得最后一个由数字和“N/A”随机混合组成的行中最后 10 个值的平均值
- ios - 在苹果商店添加评论信息截图?
- wordpress - Elementor 小部件分离问题
- python - “!”是什么意思?在python中登录吗?或者它是一个Linux commad?