gpt4 book ai didi

html - 如何在不更改内部跨度的情况下更改悬停元素?

转载 作者:太空宇宙 更新时间:2023-11-03 19:49:11 25 4
gpt4 key购买 nike

我有简单的 html 代码,我想更改 :hover 上的 h3 标记,但不影响其中的跨度。

h3 span {
color: #676767;
padding-left: 10px;
}

h3 {
font: 22px/26px Arial, Helvetica, sans-serif;
color: #ee0000;
margin: 10px 0;
}

.content:hover h3 {
text-decoration: underline;
cursor: pointer;
}

.content:hover h3 span {
padding-left: 20px;
text-decoration: none;
}
<div class="content">
<h3>Some H3 title<span class='arrow'>></span></h3>
</div>

为什么以及最好的绕行方式是什么?

最佳答案

只需将内部文本包裹在一个 span 中并为其指定一个类。

h3 span {
color: #676767;
padding-left: 10px;
}

h3 {
font: 22px/26px Arial, Helvetica, sans-serif;
color: #ee0000;
margin: 10px 0;
}

.content:hover h3 span.text {
text-decoration: underline;
cursor: pointer;
}

.content:hover h3 span.arrow {
padding-left: 20px;
}
<div class="content">
<h3><span class="text">Some H3 title</span><span class='arrow'>></span></h3>
</div>

关于html - 如何在不更改内部跨度的情况下更改悬停元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41126072/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com