Answer the question
In order to leave comments, you need to log in
How to give separate CSS to mobile devices?
Tell me, how is this done today in general? I assume it's not just media queries? Because here's an example for you - it's just that when the viewport is resized, the page styles almost do not change. But if you click on the mobile device emulator in Chrome, everything changes absolutely (you need to refresh the page after that) - https://github.com/robbyrussell/oh-my-zsh
Answer the question
In order to leave comments, you need to log in
Clumsy method:
Take something like this . Depending on what it defines there, add the necessary css files (for example, insert a tag <style src="...">
into <head>
Well, or you can simply write classes taking into account the root in <html>
(see example).
Or here .
You need to specify the media parameter in the link meta tag.
Then styles will be loaded only on mobile devices.
1) In one css, depending on the device, connect the one you need in @media
via @import
.
2) Just import and specify the media type.
htmlbook.ru/css/import
Heh, determine on the server the device from which you are viewing the site (analysis of headers from the device) and, depending on the device, give different or site templates, or simply connect different styles. For example, here's a function:
function isMobile(){
$pda_patterns = array(
'MIDP','FLY-','MMP','Mobile','MOT-',
'Nokia','Obigo','Panasonic','PPC',
'ReqwirelessWeb','Samsung','SEC-SGH',
'Smartphone','SonyEricsson','Symbian',
'WAP Browser','j2me','BREW', 'iPod', 'iPhone', 'Android'
);
$agent = $_SERVER['HTTP_USER_AGENT'];
$user_agent = strtolower($agent);
foreach($pda_patterns as $val){
$val = strtolower($val);
if(strpos($user_agent, $val) !== false){ return true; }
}
return true;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question