<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.wrapper{
display:flex;
width:200px;
flex-flow: row wrap;
}
.box{
width:50px;
height:50px;
}
.box:nth-child(3n){
background-color: #f00;
}
.box:nth-child(3n+1){
background-color: #0f0;
}
.box:nth-child(3n+2){
background-color: #00f;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</body>
</html>
See the Pen VQrWOO by Jerry (@fenture) on CodePen.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.wrapper{
display:flex;
height:200px;
flex-flow: column wrap;
}
.box{
height:50px;
}
.box:nth-child(3n){
background-color: #f00;
}
.box:nth-child(3n+1){
background-color: #0f0;
}
.box:nth-child(3n+2){
background-color: #00f;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="box">1</div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box">5</div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box">9</div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</body>
</html>
沒有留言:
張貼留言