CSS練習絕對位置於頁面寬度自適應

來源:互聯網
上載者:User

標籤:one   init   cal   doc   client   style   mil   splay   div   

<!DOCTYPE html><html><head>    <title>九宮格布局</title>    <meta name="viewport" content="width=device-width,initial-scale=1">    <link rel="stylesheet" type="text/css" href="css/index.css">    <script src="js/jquery.min.js"></script>    <script type="text/javascript">        $(function(){                    var w=$(document.body).width()+"px";        $(".wrapper").css("width",w);        $(".header").css("width",w);        $(".bottom").css("width",w);        });    </script></head><body>    <div class="wrapper">    <div class="header">首頁</div>    <div class="nav">        <ul>            <li>1</li>            <li>2</li>            <li>3</li>            <li>4</li>            <li>5</li>            <li>6</li>            <li>7</li>            <li>8</li>        </ul>    </div>    <div class="space"></div>    <div class="list-item">        <ul>            <li>1</li>            <li>2</li>            <li>3</li>            <li>4</li>            <li>5</li>            <li>6</li>            <li>7</li>            <li>8</li>            <li>9</li>            <li>0</li>        </ul>    </div>    <div class="bottom">        <ul>            <li>1</li>            <li>2</li>            <li>3</li>            <li>4</li>        </ul>    </div>    </div></body></html>

CSS

body {    margin: 0;    width: 100%;    max-width: 640px;    width: expression_r(document.body.clientWidth > 640 ? "640px": "auto")}ul {    padding: 0;}.wrapper {    display: block;    background: #fff;    font-family: "微軟雅黑";    color: #6c6c6c;}.header {    width: 100%;    background: #555;    height: 50px;    border-bottom: #c6c6c6 solid 1px;    text-align: center;    line-height: 50px;    vertical-align: middle;    color: #fff;    top: 0;    position: fixed;}.nav {    margin-top: 20px;    background: #f5f5f5;    width: 100%;}.nav ul li{    margin:10px 0px 0px 0px;    list-style: none;    width: 25%;    float: left;    text-align: center;    font-size: 200%;    color: #fac240;    line-height: 160px;    border-bottom: #f5f5f5 solid 1px;}.space {    clear:both;    width: 100%;    height: 15px;    background: #f5f5f5;}.list-item ul li {    list-style: none;    width: 100%;    height: 45px;    border-bottom: #f5f5f5 solid 1px;    line-height: 45px;    vertical-align: middle;    font-size: 200%;    color: #fac240;    text-align: center;}.bottom {    height:70px;    width: 100%;    background: #f5f5f5;    bottom: 0;    position: fixed;}.bottom ul li {    list-style: none;    width: 25%;    float: left;    line-height: 50px;    vertical-align: middle;    text-align: center;    font-size: 200%;    color: #fac240;}

 

CSS練習絕對位置於頁面寬度自適應

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.