HTML 布局的方式

1、浮动

2、定位

3、分栏布局

      column-count:auto | 整数;---控制栏数

    column-width: auto | length;---每栏的宽度

      column-gap : length ;---两栏之间的间距

      column-rule : 宽度,线型,颜色;---栏与栏的间隔线 类似border,solid | dotted | dashed 实线 | 点线 | 虚线

      column-width和column-count可以让一个元素进行多列布局 column-gap和column-rule就处在相邻两列之间

<div class="con">
    <h1>大数据下个人隐私的保护分析与研究</h1>
    <div>
        一堆内容
    </div>
</div>

//-----------------css-------------------//

.con{
    width: 600px;
    column-count: 3; 分几栏
    column-gap: 10px; 每栏之间的距离
    column-rule: 3px dotted red; 栏目之间的线

  }
  .con h1{
    -webkit-column-span: all; 标题是否跨栏显示
  }

4、弹性布局

      优点:

     1 适应性强,在做不同屏幕分辨率的界面时非常实用

     2 可以随意按照宽度、比例划分元素的宽高

     3 轻松改变元素的显示顺序

       4 弹性布局实现快捷,易维护

  display:box;将一个元素的子元素以弹性布局进行布局

  box-orient:horizontal  || vertical || inherit 子元素排列方式 

  box-direction:normal || reverse || inherit 子元素的排列顺序

  box-align:start || end || center 子元素的对齐方式 (规定水平框中垂直位置 或 垂直框中水平位置)

  box-pack: start || end || center 子元素的对齐方式(规定水平框中水平位置 或 垂直框中垂直位置)

  box-flex:number;子元素如何分配剩余空间

  box-ordinal-group:number;子元素显示顺序

<style>
    body,html{
      width: 100%;
      height: 100%;
      display: -webkit-box;
      -webkit-box-orient:vertical;
      -webkit-box-align:center;
      -webkit-box-pack:center;
    }
    .con{
      width: 90%;
      height: 90%;
      display: -webkit-box;
      -webkit-box-orient:vertical;
      border: 1px solid red;
    }
    .con .head{
      height: 200px;
      display: -webkit-box;
      -webkit-box-orient:horizontal;
    }
    .con .head .logo{
      width: 100px;
      height: 200px;
      background: pink;
    }
    .con .head .logoCon{
      height: 200px;
      -webkit-box-flex:1;
      background: green;
    }
    .con .content{
      -webkit-box-flex:1;
      background: orange;
      display: -webkit-box;
      -webkit-box-orient:horizontal;
      -webkit-box-direction:reverse;
    }
    .content div{
      width: 200px;
      text-align: center;
    }
    .con .footer{
      height: 100px;
      background: blue;
    }
  </style>
</head>
<body>
<div class="con">
  <div class="head">
    <div class="logo"></div>
    <div class="logoCon"></div>
  </div>
  <div class="content">
    <div class="con1">111</div>
    <div class="con2">222</div>
    <div class="con3">333</div>
  </div>
  <div class="footer">
  </div>
</div>

5、响应式布局

一个网站能够兼容多个终端---而不是为每个终端做一个特定的版本

  @media all(用于所有的设备) || screen (用于电脑屏幕,平板电脑,智能手机等)  and|not|only(三个关键字可以选)

<style media="screen">
    @media screen and (max-width:600px){
      .con{
        background:red;
      }
    }
    @media screen and (min-width:600px) and (max-width:800px){
      .con{
        background:blue;
      }
    }
    @media screen and (min-width:800px){
      .con{
        background:green;
      }
    }
    .con{
      width: 100%;
      height: 100px;
    }
  </style>
</head>
<body>
  <div class="con">

  </div>
</body>
发布了44 篇原创文章 · 获赞 15 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/Sunshine0508/article/details/90769910
今日推荐