css媒体查询/jquery mobile根据不同设备设定不同布局

在单一文件下,css定义方式如下:

@media (min-width: 1001px) {

sidebar ul li a:after {

content: " (" attr(data-email) ")";
font-size: 11px;
font-style: italic;
color: #666;

}
}

@media (max-width: 1000px) and (min-width: 700px) {

sidebar ul li a:before {

content: "Email: ";
font-style: italic;
color: #666;

}
}

@media (max-width: 699px) and (min-width: 520px), (min-width: 1151px) {

sidebar ul li a {

padding-left: 21px;
background: url(../images/email.png) left center no-repeat;

}
}
如果在想在不同的设备下引入不同的css,可以做如下定义:


<link rel="stylesheet" href="smartphone.css" 
media="only screen and (min-device-width : 320px) 
and (max-device-width : 480px)">

<link rel="stylesheet" href="smartphone-landscape.css" 
media="only screen and (min-width : 321px)">

<link rel="stylesheet" href="smartphone-portrait.css" 
media="only screen and (max-width : 320px)">

<link rel="stylesheet" href="ipad.css" 
media="only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px)">

<link rel="stylesheet" href="ipad-landscape.css" 
media="only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape)">

<link rel="stylesheet" href="ipad-portrait.css" 
media="only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait)">

<link rel="stylesheet" href="widescreen.css" 
media="only screen and (min-width : 1824px)">

<link rel="stylesheet" href="iphone4.css" 
media="only screen 
and (-webkit-min-device-pixel-ratio : 1.5), 
only screen and (min-device-pixel-ratio : 1.5)">

你可能感兴趣的:(css媒体查询/jquery mobile根据不同设备设定不同布局)