为什么链接效应不适用于帖子中的所有链接?
我正在使用jekyll创建博客,主题为 indigo 。我决定使用网络上发现的SASS代码发挥链接效果。问题是,它并未显示在所有链接上。
这是代码:
a:not(.exception) {
text-decoration: none;
color: #222;
font-weight: 700;
position: relative;
}
a:not(.exception)::before {
content: "";
background-color: #0396da;
position: absolute;
left: 0;
bottom: 1px;
width: 100%;
height: 8px;
z-index: -1;
transition: all 0.3s ease-in-out;
}
a:not(.exception):hover::before {
bottom: 0;
height: 100%;
}
<p>
Totam dolor aperiam <a href="https://example.com">consectetur</a>. Cum
quia itaque ut
<a href="https://example.com">ipsum laudantium rerum</a> consequatur.
Soluta ex <a href="https://example.com">itaque repellat quas</a>.
Voluptas ut similique saepe voluptatem eos architecto quaerat et.
</p>
为什么会发生这种情况?谢谢。
I'm creating a blog using Jekyll, and a theme called Indigo. I decided to put on a link effect, using Sass code I found on the net. Problem is, it's not showing up on all the links.
Here's the code:
a:not(.exception) {
text-decoration: none;
color: #222;
font-weight: 700;
position: relative;
}
a:not(.exception)::before {
content: "";
background-color: #0396da;
position: absolute;
left: 0;
bottom: 1px;
width: 100%;
height: 8px;
z-index: -1;
transition: all 0.3s ease-in-out;
}
a:not(.exception):hover::before {
bottom: 0;
height: 100%;
}
<p>
Totam dolor aperiam <a href="https://example.com">consectetur</a>. Cum
quia itaque ut
<a href="https://example.com">ipsum laudantium rerum</a> consequatur.
Soluta ex <a href="https://example.com">itaque repellat quas</a>.
Voluptas ut similique saepe voluptatem eos architecto quaerat et.
</p>
Why could this happen? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题会影响被迫在两行之间打破的每个链接。原因是效果的执行方式,伪元素::在创建一个矩形之前,该矩形无法分裂以跟随单词流。提出解决方案:
白空间:NowRap;
The issue affects every link that is forced to break between two lines. The cause is the way the effect is carried out, pseudo element ::before creates a single rectangle that has no way of splitting up to follow words flow. Posible solutions:
white-space: nowrap;