css布局之 - flex布局

<!DOCTYPE html>
<html>
<head>
	<title>test</title>
	<style type="text/css">
	  html *{
        padding: 0;
        margin: 0;
      }
      .layout article div{
        min-height: 100px;
      }

      .d1{
      display: flex; /*设置为弹性布局*/
      flex-direction: row; /*设置主轴的方向(row | row-reverse | column | column-reverse)*/
      flex-wrap: wrap; /*设置换行方式(flex-wrap: nowrap | wrap | wrap-reverse)*/
      justify-content: center; /*设置在主轴上的对齐方式(flex-start | flex-end | center | space-between | space-around)*/
      align-items: center; /*设置在交叉轴上的对齐方式(flex-start | flex-end | center | baseline | stretch)*/
      
      /*设置多轴线的对齐方式,如果项目只有一根轴线,该属性不起作用(flex-start | flex-end | center | space-between | space-around | stretch)*/
      /*align-content: center;*/

      width: 100%;
      height: 200px;
      background-color: #F1F1F1;
    }
    .child{
      width: 200px;
      height: 50px;
      background-color: red;
      margin-left: 10px;
    }
	</style>
</head>
<body>
<section class="layout flexbox">
      <style>
        .layout.flexbox{
          margin-top: 100px;
        }
        .layout.flexbox .left-center-right{
          display: flex;
        }
        .layout.flexbox .left{
          width: 300px;
          background: red;
        }
        .layout.flexbox .center{
          flex:1;
          background: yellow;
        }
        .layout.flexbox .right{
          width: 300px;
          background: blue;
        }
      </style>
      <h1>三栏布局</h1>
      <article class="left-center-right">
        <div class="left"></div>
        <div class="center">
          <h2>flex解决方案</h2>
          <p>http://www.runoob.com/w3cnote/flex-grammar.html</p>
        </div>
        <div class="right"></div>
      </article>
    </section>

    <section style="margin-top: 50px">
      <div class="d1">
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
      </div>
    </section>
</body>
</html>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值