gpt4 book ai didi

html - :link do in CSS? 是什么

转载 作者:行者123 更新时间:2023-11-28 14:54:50 25 4
gpt4 key购买 nike

因此,虽然有一个带有类 btn 的标签,但我可以通过在我的 CSS 中使用 .btn 来设置它的样式。然而,有人说使用 .btn:link 而不是仅使用 .btn 来设置按钮样式是更好的做法。使用 :hover 对输出有明显的影响。但我想知道使用或不使用 :link

样式之间到底有什么区别

.btn:link {
background-color: #67c5fc;
border-radius: 100px;
padding: 10px;
text-decoration: none;
color: #000;
}

.btn:hover {
background-color: #0082ce;
cursor: pointer;
}

.btn2 {
background-color: #48c964;
border-radius: 100px;
padding: 10px;
text-decoration: none;
color: #000;
}

.btn2:hover {
background-color: #2eaa49;
cursor: pointer;
}
<a href="#" class="btn">Button-with-:link</a>
<a href="#" class="btn2">Button-without-:link</a>

最佳答案

这里解释一下:

The :link CSS pseudo-class represents an element that has not yet been visited. It matches every unvisited <a>, <area>, or <link> element that has an href attribute.


默认情况下,大多数浏览器会为访问过的链接应用特殊的颜色值。当您使用 :link您可以声明新样式而不是默认定义

在这里了解更多:https://developer.mozilla.org/en-US/docs/Web/CSS/:link

关于html - :link do in CSS? 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51148763/

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