javascript - Conditional stylesheet by useragent -
what best way take stylesheet shown depending on useragent?
example, want show css style android , different 1 iphone.
is possible css only? can utilize media queries?thanks in advance
with net explorer can utilize conditional comments (http://msdn.microsoft.com/en-us/library/ms537512.aspx) include stylesheets in specific browser. technique not work in other browsers, , believe not work in latest version of net explorer.
to knowledge, way accomplish javascript. simplest method add together class html tag of page (i.e. ".android" or ".iphone") javascript based on user agent string. in css reference .android or .iphone in stylesheet target 1 or other.
however, best approach avoid doing specific browser detection whenever possible. feature detection preferred approach (http://www.joezimjs.com/javascript/feature-detection-vs-browser-detection/). exception intentions have different theme based on device.
see ismobile javascript library (https://github.com/kaimallea/ismobile) observe apple or android device. long stylesheet isn't huge each theme, recommend merging android , apple stylesheets one. utilize ismobile library little custom javascript add together necessary css class html tag.
javascript html5 css3
No comments:
Post a Comment