zoukankan      html  css  js  c++  java
  • 简单的CSS3实现响应式布局

    css3的@media属性实现页面响应式布局示例代码

    <html>
    <head>
    <style>

    * {
    margin:0;
    padding:0;
    }
    .ul {
    background-color:rgb(134, 170, 209);
    height: 55px;
    }
    .ul li {
    float:left;
    list-style: none;
    background-color:rgb(134, 170, 209);
    20%;
    height: 100%;
    }
    .item {
    display: block;
    text-align:center;
    line-height: 49px;
    height: 100%;
    transition: all 0.5s;
    -moz-transition: all 0.5s; /* Firefox 4 */
    -webkit-transition: all 0.5s; /* Safari 和 Chrome */
    -o-transition: all 0.5s;
    cursor:pointer;
    }
    .item:hover {
    background-color:rgb(168, 209, 253);

    }
    @media only screen and (max- 400px) {
    .ul li {
    100%;
    height: 100%;
    }
    }
    </style> 

    </head> 

    <body class="sapUiBody">
    <ul class="ul">
    <li><a class="item">Home</a></li>
    <li><a class="item">First</a></li>
    <li><a class="item">Second</a></li>
    <li><a class="item">Thirdly</a></li>
    <li><a class="item">Fourth</a></li>
    </ul>
    </body>

    </html>

    注意的是@media属性必须写在下面,从而覆盖上面的css 

  • 相关阅读:
    数组中出现次数超过一半的数字
    字符串的排列(important)
    #pragma mark指令的作用
    类的声明和实现
    OC比C中,新增的数据类型
    NSLog (Log信息的输出)
    C语言中文件相关操作
    static 及 extern
    C语言预处理命令
    结构体
  • 原文地址:https://www.cnblogs.com/chjb/p/4275481.html
Copyright © 2011-2022 走看看