css - 如果是 CSS 中的伪元素和类,顺序很重要

标签 css pseudo-element pseudo-class

<分区>

如果我将多个伪元素/类应用到单个元素中,那么在处理两个/所有元素之前定义(为一个元素编写代码)很重要。

    a:link{
    color: cyan;
          }
    a:visited{
    color:orange;
             }

    a:active{
    color:yellow;
            }
    a:hover{
    text-decoration:none;
    font-size:1.4rem;
           }

最佳答案

是的!顺序很重要。根据文档-

a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective! a:active MUST come after a:hover in the CSS definition in order to be effective!

关于css - 如果是 CSS 中的伪元素和类,顺序很重要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56864710/

上一篇:javascript - 如果悬停在其他链接上,需要停用点击功能

下一篇:html - 位置 : sticky buttons not working in IE 11

相关文章:

css - :not(:empty):before pseudo-classes/elements combination

css - 如何使用::after 定位 CSS 三 Angular 形?

html - CSS Float 添加到按钮的高度

html - 为什么转换会破坏位置为 :fixed? 的元素的尺寸

html - 以不同方式设置表格奇数/偶数行的样式

html - 如何创建一个具有圆形底部但保持曲率半径的容器?

css - 如何设置第一个元素显示 : none;?

html - 如何右对齐李?

html - 2 div 在另一个 div 内但在文本之下

php - 我如何找出我的 CSS 不显示的原因?