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{width: 890px;margin: 40px auto;border: 1px solid #ccc;clear: both;}
.box ul{margin-right: -10px;overflow: hidden;}
.box li{width: 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!

posted @ 2014-12-04 09:11  定格的有天  Views(121)  Comments(0Edit  收藏  举报