这是HTML部分
<!DOCTYPE html>
<head>
<title>描述一个网站的名字</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/index.css"/>
</head>
<body>
<div id="div1">
根据临界点的分辨率,来写对应的自适应代码
</div>
<div class="content_info">
<ul>
<li>梅花香</li>
<li>梅花香</li>
<li>梅花香</li>
<li>梅花香</li>
<li>梅花香</li>
<li>梅花香</li>
<li>梅花香</li>
<li>梅花香</li>
<li>梅花香</li>
<li>梅花香</li>
</ul>
</div>
</body>
</html>
这是样式操作
*{
margin: 0px;
padding: 0px;
}
li{list-style: none;}
/*iPhone 5 竖屏*/
@media only screen and (min-device-width : 320px) and (max-device-width : 568px) and (orientation : portrait) {
body{
background: red;
}
}
/*iPhone 5 横屏*/
@media only screen and (min-device-width : 320px) and (max-device-width : 568px) and (orientation : landscape) {
body{
background: blue;
}
}
/*苹果6Plus 下的竖屏模式*/
@media screen and (min-width: 414px) and (max-height: 736px) and (orientation : portrait){
body{
background: brown;
}
}
/*苹果6Plus 下的横屏模式*/
@media screen and (min-width: 414px) and (max-height: 736px) and (orientation : landscape){
body{
background: grey;
}
}
/*iPad 竖屏*/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
body{
background: yellow;
}
}
/*iPad 横屏*/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
body{
background: green;
}
}
/*高清屏 iPad Media Queries 即 iPad 3 & 4 的 Media Queries:*/
/*高清屏 iPad 竖屏*/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait)and (-webkit-min-device-pixel-ratio: 2) {
body{
background: red;
}
}
/*高清屏 iPad 横屏*/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape)and (-webkit-min-device-pixel-ratio: 2) {
body{
background: blue;
}
}
/*<=768的设备*/
@media (max-width:768px) {
#div1 {
width: 400px;
margin: 0 auto;
background: red;
}
#img2,#img3 {
width: 100px;
}
.content_info ul li{
float: left;
margin-left: 7px;
text-align: center;
margin-top: 4px;
width: 18%;
background: greenyellow;
}
}
/*>=768的设备*/
@media (min-width:768px) {
#div1 {
width: 600px;
margin: 0 auto;
background: blue;
}
#img2,#img3 {
width: 200px;
}
}
/*>=992的设备*/
@media (min-width:992px) {
#div1 {
width: 800px;
margin: 0 auto;
background: yellow;
}
#img2,#img3 {
width: 300px;
}
}
/*>=1200的设备*/
@media (min-width:1200px) {
#div1 {
width: 1000px;
margin: 0 auto;
background: green;
}
#img2,#img3 {
width: 400px;
}
}