<small id='cGvFh'></small><noframes id='cGvFh'>

    <i id='cGvFh'><tr id='cGvFh'><dt id='cGvFh'><q id='cGvFh'><span id='cGvFh'><b id='cGvFh'><form id='cGvFh'><ins id='cGvFh'></ins><ul id='cGvFh'></ul><sub id='cGvFh'></sub></form><legend id='cGvFh'></legend><bdo id='cGvFh'><pre id='cGvFh'><center id='cGvFh'></center></pre></bdo></b><th id='cGvFh'></th></span></q></dt></tr></i><div id='cGvFh'><tfoot id='cGvFh'></tfoot><dl id='cGvFh'><fieldset id='cGvFh'></fieldset></dl></div>
    • <bdo id='cGvFh'></bdo><ul id='cGvFh'></ul>

  1. <tfoot id='cGvFh'></tfoot>

      <legend id='cGvFh'><style id='cGvFh'><dir id='cGvFh'><q id='cGvFh'></q></dir></style></legend>

    1. 专门用于 :hover 的元素覆盖 :active 的等效类

      elements specifically for :hover overriding the an equivalent class for :active(专门用于 :hover 的元素覆盖 :active 的等效类)

          <small id='VKVHc'></small><noframes id='VKVHc'>

        1. <legend id='VKVHc'><style id='VKVHc'><dir id='VKVHc'><q id='VKVHc'></q></dir></style></legend>
              <bdo id='VKVHc'></bdo><ul id='VKVHc'></ul>

            • <i id='VKVHc'><tr id='VKVHc'><dt id='VKVHc'><q id='VKVHc'><span id='VKVHc'><b id='VKVHc'><form id='VKVHc'><ins id='VKVHc'></ins><ul id='VKVHc'></ul><sub id='VKVHc'></sub></form><legend id='VKVHc'></legend><bdo id='VKVHc'><pre id='VKVHc'><center id='VKVHc'></center></pre></bdo></b><th id='VKVHc'></th></span></q></dt></tr></i><div id='VKVHc'><tfoot id='VKVHc'></tfoot><dl id='VKVHc'><fieldset id='VKVHc'></fieldset></dl></div>

                <tbody id='VKVHc'></tbody>

              <tfoot id='VKVHc'></tfoot>
              • 本文介绍了专门用于 :hover 的元素覆盖 :active 的等效类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的代码有一个背景,其字体颜色分配给一个类,然后有单独的类用于更改 :hover 或 :active 上的颜色,但除非我删除 :hover 特定类,否则不会触发 :active 状态.CODEPEN

                I have code to have a background with a font color assigned with one class then have separate classes for changing the color on :hover or :active but the :active state does not trigger unless I remove the :hover specific class. CODEPEN

                HTML:

                <div class="backgroundRed backgroundGreenHover backgroundBlueActive" style="width: 100px; height: 100px;"></div>
                

                CSS:

                .backgroundRed, .backgroundRedHover:hover, .backgroundRedActive:active{background:red;}
                    .backgroundGreen, .backgroundGreenHover:hover, .backgroundGreenActive:active{background:green;}
                    .backgroundBlue, .backgroundBlueHover:hover, .backgroundBlueActive:active{background:blue;}
                

                推荐答案

                :active 伪类应该在 :hover 之后,否则 :hover 覆盖(链接相关的伪类的顺序是::link | :visited | :hover | :active.).您的代码示例按预期工作,但如果您更改类 :active 伪类永远不会应用.

                :active pseudo-class should go after :hover, otherwise the :hover overwrites (The order for the link-relates pseudo-clasess is: :link | :visited | :hover | :active.). You code example works as expected but if you change the classes the :active pseudo-class never applies.

                .backgroundRed,
                .backgroundRedHover:hover,
                .backgroundRedActive:active {
                  background: red;
                }
                
                .backgroundGreen,
                .backgroundGreenHover:hover,
                .backgroundGreenActive:active {
                  background: green;
                }
                
                .backgroundBlue,
                .backgroundBlueHover:hover,
                .backgroundBlueActive:active {
                  background: blue;
                }

                <div class="backgroundRed backgroundBlueHover backgroundGreenActive" style="width: 100px; height: 100px;"></div>

                您需要更多的 CSS 行,但在 :hover 之后使用 :active 重新排序类可以正常工作.

                You need more CSS lines but reordering the classes with :active after the :hover works fine.

                .backgroundRed,
                .backgroundRedHover:hover {
                  background: red;
                }
                
                .backgroundGreen,
                .backgroundGreenHover:hover {
                  background: green;
                }
                
                .backgroundBlue,
                .backgroundBlueHover:hover {
                  background: blue;
                }
                
                .backgroundRedActive:active {
                  background: red;
                }
                
                .backgroundGreenActive:active {
                  background: green;
                }
                
                .backgroundBlueActive:active {
                  background: blue;
                }

                <div class="backgroundRed backgroundBlueHover backgroundGreenActive" style="width: 100px; height: 100px;"></div>

                这篇关于专门用于 :hover 的元素覆盖 :active 的等效类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div?(如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?) - IT屋-程序员软件开发技术分享社
                Scale background image to fit ie8 window(缩放背景图像以适合 ie8 窗口)
                @fontface in IE7 (IETEster) not working properly(IE7 (IETEster) 中的@fontface 无法正常工作)
                Safari 5.1 breaks CSS table cell spacing(Safari 5.1 打破 CSS 表格单元格间距)
                Put in bold part of description in metatag Drupal module(将描述的粗体部分放在元标记 Drupal 模块中)

                  <bdo id='rDDS2'></bdo><ul id='rDDS2'></ul>

                    1. <tfoot id='rDDS2'></tfoot>
                        <tbody id='rDDS2'></tbody>
                    2. <small id='rDDS2'></small><noframes id='rDDS2'>

                      <legend id='rDDS2'><style id='rDDS2'><dir id='rDDS2'><q id='rDDS2'></q></dir></style></legend>
                        • <i id='rDDS2'><tr id='rDDS2'><dt id='rDDS2'><q id='rDDS2'><span id='rDDS2'><b id='rDDS2'><form id='rDDS2'><ins id='rDDS2'></ins><ul id='rDDS2'></ul><sub id='rDDS2'></sub></form><legend id='rDDS2'></legend><bdo id='rDDS2'><pre id='rDDS2'><center id='rDDS2'></center></pre></bdo></b><th id='rDDS2'></th></span></q></dt></tr></i><div id='rDDS2'><tfoot id='rDDS2'></tfoot><dl id='rDDS2'><fieldset id='rDDS2'></fieldset></dl></div>