How to apply conditional css for IE7 for drupal 7?
I have one file css_browser_selector.js file in sites/all/js and the code of that file is as given below:
function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|/)(\d+)/.test(ua)?' '+o+RegExp.开发者_开发问答$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
I have applied different css on different browsers using class of that browser from the code written above.The code is working for every browser but its not working on IE6,IE7.There are two default files of ie6 and ie7 in drupal 6 but these files are also not working.I dont know how to make changes in IE browser.Your help willbe appreciated.
Thankz in advance.
I guess that you have lots of css duplication in that. I bet that only IE dosn't work and css is for rest is common (if you want anyone to read you code, don't paste its inline/minified version).
Check out this, that's how most people do it. http://www.webdevout.net/css-hacks#conditional_comments
If you want really different CSS on each browser paste you JS's code redable verion or use this http://www.webdevout.net/css-hacks#conditional_comments-css_hack in combination with your solution to do it in ugly way.
Use this module http://drupal.org/project/conditional_styles
It's pretty straight forward how to do it just enable to module, add this line to your theme .info file
stylesheets-conditional[IE 7][all][] = ie7.css
then add the file ie7.css to your theme.
精彩评论