响应式

作者: 洛洛kkkkkk | 来源:发表于2017-04-18 19:25 被阅读0次
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            div{
                width: 30%;
                margin: 1%;
                height: 200px;
                background-color: cyan;
                float: left;
            }
            /*媒体查询,固定的写法。
             and 后面跟着的()里面是条件
             媒体查询相当于是另外一种新的布局方式,当条件满足之后,
             就按照媒体查询里面的样式去修改元素*/
            @media only screen and (max-width: 900px) {
                div{
                    width:40%;
                    background-color: yellowgreen;
                    
                    }
            }
        </style>
    </head>
    <body>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </body>
</html>

相关文章