You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

86 lines
1.5 KiB

<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#div0 {
width: 100px;
height: 500px;
}
#div0 div {
float: left;
height: 200px
}
/* 一行三个 div */
@media screen and (min-device-width: 400px) and (max-device-width: 500px) {
#div0 div {
width: 33.3%;
}
#div0 div:nth-child(1) {
background-color: aqua;
}
#div0 div:nth-child(2) {
background-color: red;
}
#div0 div:nth-child(3) {
background-color: green;
}
}
/* 两行三个 div */
@media screen and (min-device-width: 300px) and (max-device-width: 399px) {
#div0 div {
width: 50%;
}
#div0 div:nth-child(1) {
background-color: aqua;
}
#div0 div:nth-child(2) {
background-color: red;
}
#div0 div:nth-child(3) {
background-color: green;
}
}
/* 三行三个 div */
@media screen and (min-device-width: 200px) and (max-device-width: 299px) {
#div0 div {
width: 100%;
}
#div0 div:nth-child(1) {
background-color: aqua;
}
#div0 div:nth-child(2) {
background-color: red;
}
#div0 div:nth-child(3) {
background-color: green;
}
}
</style>
</head>
<body>
<div id="div0">
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>