javascript - 在悬停时隐藏我的 div 但显示另一个 - HTML/CSS
问题描述
我有三段
当我将鼠标悬停在已经显示的那个上时,我想在它下面显示第二段并用第三段替换第一段?
使用我的css,因为当我将鼠标悬停在第一段上时它会显示它和第二段,当我尝试同时说“阻止”第一段并显示第三段时,用户界面会变得疯狂,因为它同时试图阻止和显示,我能做些什么?
.nodeParagraph {
font-size: 14px;
letter-spacing: 0.03px;
cursor: pointer;
font-family: $font-family-base;
position: relative;
font-weight: 300;
z-index: 10000000;
left: 20px;
top: 20px;
width: 265px;
}
.nodeParagraph:hover+.nodeParagraph1 {
display: block;
}
.nodeParagraph1 {
font-size: 14px;
letter-spacing: 0.03px;
cursor: pointer;
font-family: $font-family-base;
position: relative;
font-weight: 300;
z-index: 10000000;
left: 47.5px;
top: 10px;
width: 265px;
display: none;
}
.nodeParagraph2 {
font-size: 14px;
letter-spacing: 0.03px;
cursor: pointer;
font-family: $font-family-base;
position: relative;
font-weight: 300;
z-index: 10000000;
left: 20px;
top: 20px;
width: 265px;
}
.nodeParagraph:hover {
overflow: visible;
white-space: normal;
width: auto;
}
<p class="nodeParagraph"> I am the greatest in the worl... </p>
<p class="nodeParagraph1"> world </p>
<p class="nodeParagraph2"> I am the greatest in the </p>
预期结果:
I am the greatest in the
world
解决方案
检查此代码段,它可能会对您有所帮助。
.nodeParagraph {
font-size: 14px;
letter-spacing: 0.03px;
cursor: pointer;
font-family: $font-family-base;
position: relative;
font-weight: 300;
z-index: 10000000;
left: 20px;
top: 20px;
width: 265px;
}
.nodeParagraph:hover + .nodeParagraph1 {
display: block;
}
.nodeParagraph1 {
font-size: 14px;
letter-spacing: 0.03px;
cursor: pointer;
font-family: $font-family-base;
position: relative;
font-weight: 300;
z-index: 10000000;
left: 47.5px;
top: 10px;
width: 265px;
display: none;
}
.nodeParagraph2 {
font-size: 14px;
letter-spacing: 0.03px;
cursor: pointer;
font-family: $font-family-base;
position: relative;
font-weight: 300;
z-index: 10000000;
left: 20px;
top: 20px;
width: 265px;
}
.nodeParagraph .show-on-hover{
display: none;
}
.nodeParagraph:hover .hide-on-hover{
display: none;
}
.nodeParagraph:hover .show-on-hover{
display: block;
}
<p class="nodeParagraph">
<span class="hide-on-hover">I am the greatest in the worl...</span>
<span class="show-on-hover">I am the greatest in the</span>
</p>
<p class="nodeParagraph1"> world </p>
推荐阅读
- tensorflow - 将字符串解码为 RLE 格式以进行分段可视化
- linux - 简单的 FASTA txt 分离
- javascript - 如何在页面完全重新加载之前重定向页面?
- javascript - 为什么我无法获得单选按钮的值?
- google-cloud-platform - 如何为 GCP 服务帐号创建资源级权限
- docker - Dotnet Core 3.0 WebAPI 服务部署在 Kubernetes 集群环境
- r - 使用并将当前列名粘贴到 mutate case_when
- ios - 当在 Flutter 中的 iOS 上强制横向方向时,如何在不旋转相机视图的情况下旋转设备?
- javascript - 我正在使用 javascript 制作一些样式按钮,但它们不起作用
- python - 如何在元素树中获取 find() 方法返回的元素的完整 Xpath