[JavaScript] use JavaScript to modify browser private attributes

Source: Internet
Author: User

Currently, many CSS attributes are implemented in private mode. If you want to use them, you need to add a bunch of broken prefixes,-moz-,-MS-,-o-,-WebKit -; if you change a value in the style sheet, it is very troublesome to change all the new values.

 

Or it is very troublesome to use Dom style to set the style of an element. Most of them are camps. Firefox is an alternative, and the encryption transition should be handled like this, it does not work well whether it uses regular expressions or other methods.

Small and simple encapsulation of a method, it is good to use.

It is convenient to directly inject or use csstext of Dom style and copy it to the style sheet after calling it.

 

 
Fixcss ('transition ', 'all. 8 s response-in 1s'); function fixcss (A, P) {return '-moz-#: @;-MS-#: @;-o -#:@; -WebKit -#:@;#:@;'. replace (/#: @/G, A + ':' + p );}

After this method is called, such a string is returned.

 

 
"-Moz-transition: All. 8 s bytes-in 1 s;-MS-transition: All. 8 s bytes-in 1 s;-o-transition: All. 8 s bytes-in 1 s;-WebKit-transition: All. 8 s transition-in 1 s; transition: All. 8 s bytes-in 1 s ;"

After csstext is used, the browser only recognizes the private partCode, Others will be ignored, so it is ideal. If you want to modify the style sheet, it is more convenient to copy and paste it.

 

However, if opera has a problem, it will assign all strings to the style, but the function is not affected.

 

Note the following:

Csstext will overwrite all values of the style.

 

 

We still have a better idea about how to process CSS private attributes. I 'd like to tell you a little bit. Thank you!

 

PS: CSS has entered the css4 era, and mediaquery has been incorporated into the standard.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.