Home Web Front-end HTML Tutorial JS determines whether the browser supports a certain CSS3 attribute_html/css_WEB-ITnose

JS determines whether the browser supports a certain CSS3 attribute_html/css_WEB-ITnose

Jun 24, 2016 am 11:58 AM
css3 js judgment support

1. Introduction

The emergence of CSS3 has made the performance of browsers more colorful. The one with the greatest impact is animation. When writing animations on a daily basis, it is necessary to determine in advance whether the browser supports it. , especially when writing CSS3 animation libraries. For example, transition animation-play-state is only supported by some browsers.

2. Detection method

The following method can use a script to determine whether the browser supports a certain CSS3 attribute:

Js code

  1. /**
  2. * Determine whether the browser supports a certain CSS3 attribute
  3. * @param {String} attribute name
  4. * @return {Boolean} true/false
  5. * @version 1.0
  6. * @author ydr.me
  7. * April 4, 2014 14:47:19
  8. */
  9. function supportCss3(style) {
  10. var prefix = ['webkit', 'Moz', 'ms', 'o'],
  11. i,
  12. humpString = [],
  13. htmlStyle = document.documentElement.style,
  14. _toHumb = function (string) {
  15. return string.replace(/-(w)/g, function ($0, $1) {
  16. return $1.toUpperCase();
  17. });
  18. };
  19. for (i in prefix) humpString.push(_toHumb(prefix[i] '-' style));
  20.  
  21. humpString.push(_toHumb(style));
  22.                                     ] in htmlStyle) return true;
  23. return false;
  24. Js code
  25. alert(supportCss3('animation-play-state'));
  26. 4 , Reference materials
  27. http://note.rpsh.net/posts/2011/05/20/css
http://ecd.tencent.com/css3/guide.html

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Recommended: Excellent JS open source face detection and recognition project Recommended: Excellent JS open source face detection and recognition project Apr 03, 2024 am 11:55 AM

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages ​​and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

How to fix Windows Hello unsupported camera issue How to fix Windows Hello unsupported camera issue Jan 05, 2024 pm 05:38 PM

When using Windows Shello, a supported camera cannot be found. The common reasons are that the camera used does not support face recognition and the camera driver is not installed correctly. So let's take a look at how to set it up. Windowshello cannot find a supported camera tutorial: Reason 1: The camera driver is not installed correctly 1. Generally speaking, the Win10 system can automatically install drivers for most cameras, as follows, there will be a notification after plugging in the camera; 2. At this time, we open the device Check the manager to see if the camera driver is installed. If not, you need to do it manually. WIN+X, then select Device Manager; 3. In the Device Manager window, expand the camera option, and the camera driver model will be displayed.

Does PyCharm Community Edition support enough plugins? Does PyCharm Community Edition support enough plugins? Feb 20, 2024 pm 04:42 PM

Does PyCharm Community Edition support enough plugins? Need specific code examples As the Python language becomes more and more widely used in the field of software development, PyCharm, as a professional Python integrated development environment (IDE), is favored by developers. PyCharm is divided into two versions: professional version and community version. The community version is provided for free, but its plug-in support is limited compared to the professional version. So the question is, does PyCharm Community Edition support enough plug-ins? This article will use specific code examples to

Pros and Cons Analysis: A closer look at the pros and cons of open source software Pros and Cons Analysis: A closer look at the pros and cons of open source software Feb 23, 2024 pm 11:00 PM

Pros and cons of open source software: Understanding the pros and cons of open source projects requires specific code examples In today’s digital age, open source software is getting more and more attention and respect. As a software development model based on the spirit of cooperation and sharing, open source software is widely used in different fields. However, despite the many advantages of open source software, there are also some challenges and limitations. This article will delve into the pros and cons of open source software and demonstrate the pros and cons of open source projects through specific code examples. 1. Advantages of open source software 1.1 Openness and transparency Open source software

How to determine whether a date is the previous day in Go language? How to determine whether a date is the previous day in Go language? Mar 24, 2024 am 10:09 AM

Question: How to determine whether the date is the previous day in Go language? In daily development, we often encounter situations where we need to determine whether the date is the previous day. In the Go language, we can implement this function through time calculation. The following will be combined with specific code examples to demonstrate how to determine whether the date is the previous day in Go language. First, we need to import the time package in the Go language. The code is as follows: import("time") Then, we define a function IsYest

The relationship between js and vue The relationship between js and vue Mar 11, 2024 pm 05:21 PM

The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.

jQuery usage practice: several ways to determine whether a variable is empty jQuery usage practice: several ways to determine whether a variable is empty Feb 27, 2024 pm 04:12 PM

jQuery is a JavaScript library widely used in web development. It provides many simple and convenient methods to operate web page elements and handle events. In actual development, we often encounter situations where we need to determine whether a variable is empty. This article will introduce several common methods of using jQuery to determine whether a variable is empty, and attach specific code examples. Method 1: Use the if statement to determine varstr="";if(str){co

Is enabling secure boot a necessary condition for upgrading win11? How to turn on secure boot Is enabling secure boot a necessary condition for upgrading win11? How to turn on secure boot Jan 29, 2024 pm 08:33 PM

As we all know, to install the win11 system, you need to ensure that the computer supports TPM2.0 and turns on secure boot. If your computer fails to install win11, it may be because secure boot is not turned on. The following are tutorials for enabling secure boot on some brands of computers. I hope it will be helpful to you. What should I do if I get a message that secure boot must be supported when upgrading to win11? 1. ASUS motherboard 1. First, we switch to Chinese, and then press F7 on the keyboard to open the advanced settings according to the prompts. 3. Then select Key Management. 2. Lenovo computers 1. For Lenovo computer models before 2020, you need to use F2 to enter the bios settings, and then select security above. 2. In the security tab, drop secureboot and change it to E

See all articles