(浮動+盒模型+無序列表)實現切換圖片效果

來源:互聯網
上載者:User

下面做個毒霸首頁中圖片切換的效果,如下:

實現代碼如下:

<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title></title>    <style>        .zong {            width: 600px;            height: 70px;            background-color: gray;        }        .nav {            width: 50px;            height: 70px;            background-color: darkblue;            float: left;        }        .nav ul {            margin-top: 0px;            padding: 0px;        }        .nav ul li {            margin-top: 1px;            list-style-type: none;            width: 49px;            height: 16.2px;            font-size: small;            background-color: crimson;            text-align: center;            line-height: 17px;            float:left;        }        .content {            margin-left: 51px;            height: 70px;            background-color: chartreuse;        }        .content ul {            padding: 0px;            margin: 0px;            margin-left: 1px;        }        .content ul li {            list-style-type: none;            width: 108px;            height: 70px;            float: left;            text-align: center;            margin-left: 1px;        }    </style></head><body><div class="zong">    <div class="nav">        <ul>            <li>熱門</li>            <li>電視劇</li>            <li>電影</li>            <li>娛樂</li>        </ul>    </div>    <div class="content">        <ul>            <li><img src="pic/01.png"/></li>            <li><img src="pic/02.png"/></li>            <li><img src="pic/03.png"/></li>            <li><img src="pic/04.png"/></li>            <li><img src="pic/05.png"/></li>        </ul>    </div></div></body></html>

以上代碼運行後的效果如下:

總結:
1 總的在一個div下
2 左側導航是一個div,導航右側圖片地區整體是一個div
3 導航左浮動,圖片地區設定margin-left
4 導航內部是一個無序列表
5 圖片地區也是一個無序列表,每一個清單項目被設定成左浮動
6 注意調整盒子的margin,特別注意是ul元素的margin和padding清零

兩種辦法可以輕鬆實現兩欄的效果
1 一個左浮動,一個設定margin-left
2 兩個都設定左浮動

FR:海濤高軟(QQ技術交流群:386476712)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.