zoukankan      html  css  js  c++  java
  • 实现三个div,固定左右两边的div宽为200,中间的div宽度自适应的四种方法

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>实现三个div,固定左右两边的div宽为200,中间的div宽度自适应的四种方法</title>
        <style type="text/css">
            html,body{
                width:100%;
                height:100%;
                margin:0;
                padding:0;
                color: #fff;
                text-align: center;
                line-height: 100px;
            }
            .clear:after{content:"";display:block;height:0;clear:both;}
            /*float法*/
            .left{
                float: left;
                width:200px;
                height: 100px;
                background:Red;
            }
            .right{
                float: right;
                width:200px;
                height: 100px;
                background:green;
            }
            .center{
                margin-left: 200px;
                margin-right: 20px;
                height: 100px;
                background:blue;
            }
            /*position*/
            .position{
                position: relative;
                margin-bottom: 20px;
            }
            .left2{
                position:absolute;
                left:0;
                top:0;
                width:200px;
                height: 100px;
                background:Red;
            }
            .right2{
                position:absolute;
                right:0;
                top:0;
                width:200px;
                height: 100px;
                background:green;
            }
            .center2{
                position:absolute;
                left:200px;
                right:200px;
                top:0; 
                background:blue;
            }
            /*table*/
            .table{
                display: table;
                width:100%;
            }
            .table .child{
                display: table-cell;
            }
            .left3{
                width:200px;
                height: 100px;
                background:Red;
            }
            .right3{
                width:200px;
                height: 100px;
                background:green;
            }
            .center3{
                height: 100px;
                background:blue;
            }
            /*flex*/
            .flex{
                display: box;
                display:-webkit-box;
                display:-moz-box;
            }
            .left4{
                width:200px;
                height: 100px;
                background:Red;
            }
            .right4{
                width:200px;
                height: 100px;
                background:green;
            }
            .center4{
                box-flex:1;
                -webkit-box-flex: 1;
                -moz-box-flex: 1;
                background: blue;
            }
        </style>
    </head>
    <body>
        <div class="clear">
            <div class="left">float法</div>
            <div class="right">float法</div>
            <div class="center">float法</div>
        </div>
        <br/>
        <div class="position clear">
            <div class="left2">position法</div>
            <div class="right2">position法</div>
            <div class="center2">position法</div>
        </div>
        <br/>
        <div class="table clear">
            <div class="left3 child">table法</div>
            <div class="center3 child">table法</div>
            <div class="right3 child">table法</div>
        </div>
        <br>
        <div class="flex clear">
            <div class="left4 child">flex法</div>
            <div class="center4 child">flex法</div>
            <div class="right4 child">flex法</div>
        </div>
    </body>
    </html>
     
    效果图如下:
  • 相关阅读:
    python按行读取并替换
    python 爬取网页内容
    file.write(str),file.writelines(sequence)
    04Spring_bean 后处理器(后处理Bean),BeanPostProcessor ,bean创建时序,动态代理
    03Spring_bean的创建和作用域以及生命周期
    02Spring_Ioc和DI介绍
    01Spring_基本jia包的导入andSpring的整体架构and怎么加入日志功能
    错题724-java
    05传智_jbpm与OA项目_部门模块中增加部门的jsp页面增加一个在线编辑器功能
    04传智_jbpm与OA项目_部门模块改进_直接在BaseAction中实现ModelDriven<T>
  • 原文地址:https://www.cnblogs.com/tanweiwei/p/10563227.html
Copyright © 2011-2022 走看看