Utilizing Modernizr and CSS3 Pie to Make ALL Your Sites CSS3 All set

Published: 03rd June 2011
Views: N/A

Modernizr, if you are not familiar with it, detects assistance for most CSS3 characteristics, and immediately adds courses to your tag centered on no matter if all those features are present or not. Instance:

Code:



The result is basic: the skill to do if statements in your css based mostly on naming conventions, for instance:

Code:

.multiplebgs div

/* properties for browsers that

support many backgrounds */



.no-multiplebgs div

/*properties

for browsers that do not */



So, with CSS3 pie, it would look some thing like this:

Code:

#divname



border-radius: 10px



.no-borderradius #divname



border-radius: 10px

behavior: url(../css/PIE.htc)



The second class only influences (and consequently only loads the htc file) for end users who do not have the border-radius characteristic readily available in their browser.

The advantages of this are quite a few. For me, the biggest relief is getting my internet explorer designs right up coming to their contemporary browser counterparts. Basically add the pie.htc file (website link below) to your css folder and you are set. Only one excess line of markup in your css files, and as a bonus, only IE renders the "behaviour:" tag so other browsers will skip above it and your consumers applying modern day browsers will not knowledge any supplemental download overhead.

This by alone is a quite very good solution to our problem. But there is a single downside. IE9 users will also have to download the PIE.htc file (about 30kb).

We could resolve this employing a conditional stylesheet:



But to me, this is a messy remedy. It involves further code that is significantly much gone from your conventional kinds. In case you at any time want to modify this model in the long run, you may have a challenging time navigating all of these disparate classes if you have a large site.

Enter Modernizr.

Modernizr is a good option to this problem (it is particularly nifty if you have already loaded the library for other reasons, but the file is a lot less than three kb gzipped both way).

Only load the modernizr.js script into your net web page and its all set, no JS coding needed:



Modernizr, if you are not acquainted with it, detects help for most CSS3 characteristics, and instantly adds courses to your tag centered on if people features are present or not. Case in point:

Code:



The consequence is very simple: the power to do if statements in your css centered on naming conventions, for case in point:

Code:

.multiplebgs div

/* properties for browsers that

help various backgrounds */



.no-multiplebgs div

/*attributes

Microsoft and Apple are absolutely dominate Providers that affect the net, how it is accessed and applied as they each present the platforms most individuals use, this offers them both an benefit when it comes to which browser people use. Lots of individuals with a lower diploma of information of this sort of factors take what they are granted with their new Pc or Mac. This gives equally Microsoft who like there individual route of browsing and Apple who want all their very own way to make everyday living challenging. I for one particular never like either Corporation, though when it comes to browsers Microsoft are the worse and no 1 need to use it.

Report this article Ask About This Article


Loading...
More to Explore