<legend id='bYow7'><style id='bYow7'><dir id='bYow7'><q id='bYow7'></q></dir></style></legend>
  1. <tfoot id='bYow7'></tfoot>

    • <bdo id='bYow7'></bdo><ul id='bYow7'></ul>

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

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

      如何在 CSS 中延迟 :hover 效果?

      时间:2023-11-01

        <tbody id='EkwVR'></tbody>

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

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

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

            • <tfoot id='EkwVR'></tfoot>
            • <i id='EkwVR'><tr id='EkwVR'><dt id='EkwVR'><q id='EkwVR'><span id='EkwVR'><b id='EkwVR'><form id='EkwVR'><ins id='EkwVR'></ins><ul id='EkwVR'></ul><sub id='EkwVR'></sub></form><legend id='EkwVR'></legend><bdo id='EkwVR'><pre id='EkwVR'><center id='EkwVR'></center></pre></bdo></b><th id='EkwVR'></th></span></q></dt></tr></i><div id='EkwVR'><tfoot id='EkwVR'></tfoot><dl id='EkwVR'><fieldset id='EkwVR'></fieldset></dl></div>
                本文介绍了如何在 CSS 中延迟 :hover 效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                有没有办法在不使用 JavaScript 的情况下延迟 :Hover 事件?我知道有一种方法可以延迟动画,但我没有看到任何延迟 :hover 事件的方法.

                我正在制作一个类似傻瓜的菜单.我想在不增加额外 JS 权重的情况下模拟 hoverIntent 的作用.我更愿意将此视为渐进式增强,而不是让 JS 成为使用菜单的必要条件.

                菜单标记示例:

                <ul><li><a href="#"><ul><li></li><li></li></ul></li><li><li></ul></div></div>

                这里是完整的演示:http://jsfiddle.net/aEgV3/

                解决方案

                如果效果是基于 CSS 的,您可以使用过渡来延迟所需的 :hover 效果.

                例如

                div{过渡:0s 背景颜色;}div:悬停{背景颜色:红色;转换延迟:1s;}

                这将延迟应用悬停效果(background-color 在这种情况下)一秒钟.

                <小时>

                悬停开启和关闭延迟演示:

                div{显示:内联块;填充:5px;边距:10px;边框:1px 实心#ccc;过渡:0s 背景颜色;转换延迟:1s;}div:悬停{背景颜色:红色;}

                <div>延迟悬停</div>

                仅在悬停时的延迟演示:

                div{显示:内联块;填充:5px;边距:10px;边框:1px 实心#ccc;过渡:0s 背景颜色;}div:悬停{背景颜色:红色;转换延迟:1s;}

                <div>延迟悬停</div>

                <小时>

                过渡的供应商特定扩展和W3C CSS3 过渡

                Is there a way to delay the :Hover event without using JavaScript? I know there is a way to delay animations, but I haven't seen anything on delaying the :hover event.

                I'm building a son-of-suckerfish like menu. I'd like to simulate what hoverIntent does without adding the extra JS weight. I'd prefer to treat this as a progressive enhancement and not make JS a requirement for using the menu.

                Example of menu markup:

                <div>
                    <div>
                        <ul>
                            <li><a href="#">
                                <ul>
                                    <li></li>
                                    <li></li>
                                </ul>
                            </li>
                            <li>
                            <li>
                        </ul>
                    </div>
                </div>
                

                Here is the full demo: http://jsfiddle.net/aEgV3/

                解决方案

                You can use transitions to delay the :hover effect you want, if the effect is CSS-based.

                For example

                div{
                    transition: 0s background-color;
                }
                
                div:hover{
                    background-color:red;    
                    transition-delay:1s;
                }
                

                this will delay applying the the hover effects (background-color in this case) for one second.


                Demo of delay on both hover on and off:

                div{
                    display:inline-block;
                    padding:5px;
                    margin:10px;
                    border:1px solid #ccc;
                    transition: 0s background-color;
                    transition-delay:1s;
                }
                div:hover{
                    background-color:red;
                }

                <div>delayed hover</div>

                Demo of delay only on hover on:

                div{
                    display:inline-block;
                    padding:5px;
                    margin:10px;
                    border:1px solid #ccc;
                    transition: 0s background-color;
                }
                div:hover{
                    background-color:red;    
                    transition-delay:1s;
                }

                <div>delayed hover</div>


                Vendor Specific Extentions for Transitions and W3C CSS3 transitions

                这篇关于如何在 CSS 中延迟 :hover 效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:CSS:悬停一个元素,多个元素的效果? 下一篇:css hover 可以在移动设备上使用吗?

                相关文章

              1. <legend id='hrgWy'><style id='hrgWy'><dir id='hrgWy'><q id='hrgWy'></q></dir></style></legend>

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

                1. <small id='hrgWy'></small><noframes id='hrgWy'>

                    <tfoot id='hrgWy'></tfoot>