想把第四,第八个li的右边距去掉,刚好可以不用换行,铺满了,然后我用.right li:nth-child(4n){margin-right:0;}居然没用,检查的时候这行代码别说划横线没执行了,根本就没有出现。然后我试了半天,把li换成ul,居然可以了。为什么这样啊
<!DOCTYPE html>
<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>
*{
margin: 0;
padding: 0;
}
.box
{
width: 1226px;
height: 614px;
background-color: pink;
}
.left{
float: left;
width: 234px;
height: 614px;
background-color: #800080;
}
.right{
float: right;
width: 978px;
height: 614px;
background-color: green;
}
ul{
list-style: none;
}
.right li{
float: left;
margin-right: 14px;
margin-bottom: 14px;
width: 234px;
height: 300px;
background-color: #87ceeb;
}
.right ul :nth-child(4n)
{
margin-right: 0;
}
</style>
</head>
<body>
<div class="box">
<div class="left"></div>
<div class="right">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
</body>
</html>