margin负值

一列li并排的时候,需要一些间距的时候,又不需要最右边或者最左边有间距。

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<style>
body,div,ul,li,img{margin: 0;padding: 0;}
li{list-style: none;}
.box{ 890px;margin: 40px auto;border: 1px solid #ccc;clear: both;}
.box ul{margin-right: -10px;overflow: hidden;}
.box li{ 290px;height: 100px;float: left;margin-right: 10px;background-color: #ccc;}
img{vertical-align: middle;}
</style>
</head>
<body>
<div class="box">
    <ul>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</div>
</body>
</html>

ok!

原文地址:https://www.cnblogs.com/freeze89/p/4142002.html