zoukankan      html  css  js  c++  java
  • 经典布局

    今天整理一下前端的几种经典布局:

    一、上中下一栏式布局

      此类布局是最简单的布局方式,直接排下来就可以了。代码如下:

      

      实现效果:

      

      上面红框里面看到body与页面之间有 一个小缝隙,那是浏览器自带的默认值导致的,直接加一个body{margin:0;} 就可以了。

      效果如下:

       

    二、左右两栏式布局

      1、浮动+普通流混合模式

       原理:left向左浮动后,right无需给宽,自动占全部宽度,需加一个margin-left来腾出left的空间。如果父元素宽度不是固定的,那么right可以随着窗口大小的变化而变化。

      html如下:

        <div class="wrap">

        <aside class="left">left</aside>

        <section class="right">right</section>

       </div>

      css如下:

      

        .wrap{width: 80%;margin:0 auto;}

      .left{width:200px;height:100px;float: left; background: #94D3A4;}

      .right{height:100px;background: #8EB6D6;margin-left:200px;}

      效果:

      

      注意:制作过程中right的宽度会占100%的宽,所以需要给right一个margin值,让出位置给left。

       2、纯浮动式

      原理:left和right都浮动,然后给父元素清除浮动即可。

      代码:

      

       <div class="wrap">

        <aside class="left">left</aside>

        <section class="right">right</section>

      </div>

     

      .wrap{width: 80%;margin:0 auto;overflow: hidden;}

    .left{width:200px;height:100px;float: left; background: #94D3A4;}

    .right{width:500px;height:100px;float:left;background: #8EB6D6;}

     

      效果:

      

       3、绝对定位

        代码:

        <div class="wrap">

        <aside class="left">left</aside>

        <section class="right">right</section>

       </div>

        

        .wrap{width:700px;margin:0 auto; position:relative;}

      .left{width:200px;height:100px; background: #94D3A4;position: absolute;top:0;left:0;}

      .right{width:500px;height:100px;background: #8EB6D6;position: absolute;top:0;right:0;}

        效果:

        

    三、左右两栏加页眉页脚

    四、左中右三栏

    五、左中右三栏加页眉页脚

  • 相关阅读:
    如何使用Python创建可视化对象
    Power Query中如何解析累积总计
    如何快速复制度量值?
    如何使用文本字段进行条件格式设置
    Power BI 3-4月功能更新培训合集
    2019微软Power BI 每月功能更新系列——Power BI 4月版本功能完整解读
    送你一份堆积柱形图小点心,请收下~
    命令行编译带外部包依赖的java源文件 [以JDBC MySQL8为例]
    JavaScript (JS)常用方法
    JDK8过渡到JDK11
  • 原文地址:https://www.cnblogs.com/sensen1400/p/8082862.html
Copyright © 2011-2022 走看看