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> $('#btnP').click(function(){ $('.top').css('pointer-events', 'none') }) </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!