Jump to content

Conditional CSS on screen resolution


Recommended Posts

Hello

How to implement conditional CSS depending on screen resolution using the following script? :

[removed]
   var screenwidth = screen.width;
   if (screenwidth <= 1024) {
     [removed]('<link rel="stylesheet" href="global.css" type="text/css" media="screen" />');
   }
   else {
     [removed]('<link rel="stylesheet" href="globalNEW.css" type="text/css" media="screen" />');
   }
[removed]



Do I have to modify header.php and header.tpl or something esle?

Link to comment
Share on other sites

Well for the moment I made the changes only in header.tpl as follows:

{literal}
[removed]
var screenwidth = screen.width;
if (screenwidth <= 1024) {
[removed]('<link href="http://myweb//themes/mytheme/css/global1.css" rel="stylesheet" type="text/css" />');
}
else {
[removed]('<link href="http://myweb//themes/mytheme/css/global.css" rel="stylesheet" type="text/css" />');
}
[removed]
{/literal}

It works perfect. But I think it is a bit "dirty" way as it uses absolute links. So how to assign CSS variables {$css_url} and {$css_url1}???? and where???

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...