码迷,mamicode.com
首页 > 其他好文 > 详细

媒体查询

时间:2019-01-03 00:39:52      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:table   fine   doc   sig   only   smart   script   hone   cep   

responsive design - On desktop PC, mobile css loads first, then it switches to the desktop version - Stack Overflow

There are few approach you can use

1st Approach by using CSS File

<link rel="stylesheet" media="screen and (min-width: 600px)" href="small.css">
<link rel="stylesheet" media="screen and (min-width: 4000px)" href="big.css">

2nd by using Javascript

if (window.matchMedia(‘screen and (min-width: 600px)‘)){
  document.write(‘<link rel="stylesheet" 
                  href="small.css">‘);
}

I suggest for better one you need use only one css file and define the concept like as below :

@media (min-width:320px)  { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ }
@media (min-width:480px)  { /* smartphones, Android phones, landscape iPhone */ }
@media (min-width:600px)  { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 > phones (Android) */ }
@media (min-width:801px)  { /* tablet, landscape iPad, lo-res laptops ands desktops */ }
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* hi-res laptops and desktops */ }

媒体查询

标签:table   fine   doc   sig   only   smart   script   hone   cep   

原文地址:https://www.cnblogs.com/jffun-blog/p/10212012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!