• CSS---左右固定,中间自适应布局


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title>宽度自适应布局</title>
            <style>
                .wrap {
                    background-color: #D66464;
                }
                .clearfix:after {
                    content: "";
                    clear: both;
                    display: block;
                }
                .left {
                    float: left;
                     100px;
                    background: #00f;
                    height: 180px;
                }
                .right {
                    float: right;
                     150px;
                    background: #0f0;
                    height: 200px;
                }
                .center {
                    background: #FFFFFF;
                    margin-left: 110px;
                    margin-right: 160px;
                    height: 150px;
                }
            </style>
        </head>
        <body>
            <div class="wrap clearfix">
                <div class="left">left,宽度固定,高度可固定也可以由内容撑开。</div>
                <div class="right">right,宽度固定,高度可固定也可以由内容撑开。</div>
                <div class="center">center,可以自适应浏览器宽度,高度可固定也可以由内容撑开。</div>
            </div>
        </body>
    </html>
    
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title>宽度自适应布局</title>
            <style>
                .wrap {
                    background-color: #FBD570;
                    margin-left: 100px;
                    margin-right: 150px;
                }
                .clearfix:after {
                    content: "";
                    clear: both;
                    display: block;
                }
                .left {
                    float: left;
                     100px;
                    background: #00f;
                    height: 180px;
                    margin-left: -webkit-calc(-100% - 100px);
                    margin-left: -moz-calc(-100% - 100px); 
                    margin-left: calc(-100% - 100px); //减号两边必须有空格         
                }
                .right {
                    float: right;
                     150px;
                    background: #0f0;
                    height: 200px;
                    margin-right: -150px;
                }
                .center {
                    background: #B373DA;
                    height: 150px;
                    float: left;
                     100%;
                }
            </style>
        </head>
        <body>
            <div class="wrap clearfix">
                <div class="center">center,可以自适应浏览器宽度,高度可固定也可以由内容撑开。</div>
                <div class="left">left,宽度固定,高度可固定也可以由内容撑开</div>
                <div class="right">right,宽度固定,高度可固定也可以由内容撑开</div>
            </div>
        </body>
    </html>
    
  • 相关阅读:
    [Dynamic Language] Python 命名参数
    [Dynamic Language] Python OrderedDict 保证按插入的顺序迭代输出
    div水平垂直居中
    项目小结(v1.2v1.4)
    如何能尽快看完一个网页的结构
    在项目中使用谁存储过程orTSQL语句
    UDP协议(数据报协议)
    风恋尘香欢迎你!!!
    .NEt牛人帮帮我!!!谢谢啦~~~
    LWUIT 简易漂亮的相册
  • 原文地址:https://www.cnblogs.com/beast-king/p/5424742.html
Copyright © 2020-2023  润新知