html - 使伪元素在悬停在其父元素的父标签上时移动

标签 html css tags pseudo-element

我想让我的伪元素的边框在其父元素的父元素悬停时移动。基本上我希望它在我将鼠标悬停在 “lk” 上时移动,而不是仅在将鼠标悬停在 “ci” 上时激活,但我似乎无法让它工作.它只适用于 div 吗?如果是这样,我愿意接受这个选项。我已经尝试过使用 div 进行类似的尝试,但我似乎仍然无法让它工作,所以我很高兴学习如何做。

HTML

<lk><de>Name:</de><ci>Luci`a Bloom</ci></lk>  

CSS

lk{
margin-right:49px;
}

de{
color:black;
font-family:karla;
font-weight:900;
border-bottom:1px solid #EAEAEA;
padding-bottom:5px;
padding-right:7px;
}

ci{
color:black;
text-transform: uppercase;
margin-left:1px;
font-family:calibri;
border-bottom:1px solid #EAEAEA;
padding-bottom:5px;
font-weight:200;
position: relative;
font-size:15px;
color: black;
width: fit-content;
margin-left:1px
} 

ci:after { 
content: "";
border-bottom:1px solid black;
width: 100%;
height: 120%;
position: absolute;
top: -5px;
z-index: 1;
 right:0px;
 transition: 2.5s;   
 }

#deetz ci:hover:after{
border-bottom:1px solid black;
transition: 2.5s;
width:0%;
}

最佳答案

我试图或多或少地理解您的问题,您希望在将鼠标悬停在整个 lk 元素上时激活伪悬停。如果是这样,请尝试将悬停伪类添加到 lk 元素并使用 > 选择器指示它需要影响的元素

lk:hover > ci:after{
border-bottom:1px solid black;
transition: 2.5s;
width:0%;
}

关于html - 使伪元素在悬停在其父元素的父标签上时移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53037558/

相关文章:

css - 如何让 <li> 在 jQuery 加载前正确显示?

css - 奇怪的行为 : Why is container height changed by bootstrap columns?

javascript - 我的网站图库

javascript - 未捕获的类型错误 : Object [object Object] has no method 'jqEasyCounter'

html - Bootstrap 导航栏 : Width of left element affects position of element in the center

html - 关于如何在网页上显示/呈现 HTML 标签的想法

video - 如果支持,请使用 HTML <video> 标签,否则使用 lightbox??? (脚本)

html - 如何在另一个div的右上角创建三 Angular 形以看起来被边框分开

html - 背景图像及其上的元素

jquery - 是否可以使用 jquery 以编程方式模拟 <a href> 标签上的点击?