css布局

作者: 寿_司 | 来源:发表于2015-12-07 00:19 被阅读0次
    • 左边定宽,右边宽度自适应
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
    /*        .left{
                background-color: #44D207;
                height: 300px;
                width: 200px;
                float: left;
            }
            .right{
                margin-left: 200px;
                height: 300px;
                background-color: #E71217;
            }*//*方法一*/
            .left{
                background-color: #44D207;
                height: 300px;    
                width: 200px;
                float: left;
                margin-right: -100%;
            }
            .rright{
                margin-left: 200px;
                background-color: #e71217;
                height: 300px;
            }
            .right{
                float: left;
                width: 100%;
            }/*方法二*/
        </style>
    </head>
    <body>
        <div class="contain">
            <div class="left"></div>
            <div class="right">
                <div class="rright"></div>
            </div>
        </div>
    </body>
    </html>
    
    • 等高自适应,两列布局
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
            .left{
                background-color: #44D207;
                width: 200px;
                float: left;
                margin-bottom: -99999px;
                padding-bottom: 99999px;
            }
            .right{
                margin-left: 200px;
                background-color: #E71217;
                margin-bottom: -99999px;
                padding-bottom: 99999px;
            }
            .contain{
                overflow: hidden;
                position: relative;
            }
            .left-bottom{
                position: absolute;
                bottom: 0;
                left: 0;
                height: 1px;
                width: 200px;
                background: #000;
            }
            .right-bottom{
                position: absolute;
                bottom: 0;
                right: 0;/*根据具体情况改变*/
                height: 1px;
                width: 200px;
                background: #000;           
            }
        </style>
    </head>
    <body>
        <div class="contain">
            <div class="left">
                <p>halou</p>
                <div class="left-bottom"></div>
                <!-- 用这些来模拟底部边框,假如必要的话 -->
            </div>
            <div class="right">
                <div class="right-bottom"></div>
            </div>
        </div>
    </body>
    </html>
    

    相关文章

      网友评论

          本文标题:css布局

          本文链接:https://www.haomeiwen.com/subject/xkhehttx.html