【原】css設定布局時,盡量天上背景色

來源:互聯網
上載者:User

如題,這樣層次關係比較瞭然。

未添加背景色
<html>
<head>
</head>
<body>
<div>
<ul style="list-style:none;">
<li>ddgd</li>
<li>dgdg</li>
<li>dgdg</li>
</ul>
</div>
</body>
</html>

 

添加背景色
<html>
<head>
</head>
<body>
<div style="background:#cccccc;">
<ul style="list-style:none;background:blue;">
<li>ddgd</li>
<li>dgdg</li>
<li>dgdg</li>
</ul>
</li>
</div>
</body>
</html>

很容易看出要讓ul左邊空隙為0,只需給它加上樣式padding:0px;margin:0px;
簡單例子説明一個簡單習慣

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.