Home  >  Article  >  Web Front-end  >  Introduction to pointer-events property in CSS3

Introduction to pointer-events property in CSS3

青灯夜游
青灯夜游Original
2018-09-25 18:02:372494browse

This chapter introduces you to a very practical attribute in CSS3: CSS3 pointer-events attribute. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Recently I discovered a CSS attribute called pointer-events, which is an attribute related to JavaScript. Pointer-events is literally translated as pointer event. When the value is set to none, it has the following related characteristics.
Prevent the user's click action from producing any effect
Prevent the display of the default mouse pointer
Prevent Hover and Active state changes in Css from triggering events
Prevent events triggered by Javascript click actions
One Isn’t it amazing how many things can be done with CSS? Let’s take a look at the compatibility situation.
IE 11
Firefox 3.6+
Chrome 4.0
Safari 6.0
Opera 15.0
iOS Safari 6.0
Android Browser 2.1
Android Chrome 18.0

View the rendering: https://runjs.cn/detail/9rxdbuin

Code:

<!DOCTYPE html>
<html> 
    <head> 
    <style>
      a.noLink{pointer-events: none;}
      .bottom { background: yellow; width: 100px; height: 100px; } 
      .top { width: 100px; height: 100px; position: absolute; top: 0; left: 0;background:rgba(0,0,0,.2);} 
      .top span{margin-top:50px;display:inline-block}
    </style>
    <script id="jquery_183" type="text/javascript" class="library" src="/js/jquery-1.8.3.min.js"></script>
    </head>
    <body> 
            <div>
                <!-- 下方div --> <div class="bottom"> <a href="www.baidu.com">bottom-百度</a> </div>
                <!-- 上方div --> <div class="top"><span>我是上层top</span></div> 
            <button id="btnP">
                添加pointer-events
                </button>
            </div>        
    </body> 
<script>
    $(&#39;#btnP&#39;).click(function(){
        $(&#39;.top&#39;).css(&#39;pointer-events&#39;, &#39;none&#39;)
    })
</script>
</html>

The above is an example of the introduction of CSS3 pointer-events attribute , you can try to compile it yourself and see the effect.

The above is the detailed content of Introduction to pointer-events property in CSS3. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn