zoukankan      html  css  js  c++  java
  • 弹性盒模型

    1、注意在使用弹性盒模型的时候 父元素必须要加display:box 或 display:inline-box
    <style>
    .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box;}
    .box div{width:100px;height:100px;background:red;border:1px solid #fff;}
    </style>
    </head>
    <body>
    <div class="box">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
    </div>
    </body>
    2、Box-orient 定义盒模型的布局方向
        •Horizontal 水平显示
        •vertical 垂直方向
    <style>
    .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box;-webkit-box-orient:vertical; }
    .box div{width:100px;height:100px;background:red;border:1px solid #fff;}
    </style>
    </head>
    <body>
    <div class="box">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
    </div>
    </body>
    3、box-direction 元素排列顺序
        •Normal 正序
        •Reverse 反序
    <style>
    .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box;-webkit-box-direction:Reverse; font-size:20px;color:#fff; }
    .box div{width:100px;height:100px;background:red;border:1px solid #fff;}
    </style>
    </head>
    <body>
    <div class="box">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
    </div>
    </body>
    4、box-ordinal-group 设置元素的具体位置
    <style>
    .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box; font-size:20px;color:#fff; }
    .box div{width:100px;height:100px;background:red;border:1px solid #fff;}
    .box div:nth-of-type(1){-webkit-box-ordinal-group:2;}
    .box div:nth-of-type(2){-webkit-box-ordinal-group:4;}
    .box div:nth-of-type(3){-webkit-box-ordinal-group:1;}
    .box div:nth-of-type(4){-webkit-box-ordinal-group:5;}
    .box div:nth-of-type(5){-webkit-box-ordinal-group:3;}
    </style>
    </head>
    <body>
    <div class="box">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
    </div>
    </body>

     5、Box-flex 定义盒子的弹性空间

      •子元素的尺寸=盒子的尺寸*子元素的box-flex属性值 / 所有子元素的box-flex属性值的和
    <style>
    .box{height:100px;border:10px solid #000;padding:10px; display:-webkit-box; font-size:20px;color:#fff; }
    .box div{height:100px;background:red;border:1px solid #fff;}
    .box div:nth-of-type(1){width:300px;}
    .box div:nth-of-type(2){-webkit-box-flex:2;}
    .box div:nth-of-type(3){-webkit-box-flex:3;}
    .box div:nth-of-type(4){-webkit-box-flex:4;}
    .box div:nth-of-type(5){-webkit-box-flex:5;}
    /*子元素的尺寸=盒子的尺寸*子元素的box-flex属性值 / 所有子元素的box-flex属性值的和 */
    </style>
    </head>
    <body>
    <div class="box">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
    </div>
    </body>

    6、box-pack 对盒子富裕的空间进行管理

      •Start 所有子元素在盒子左侧显示,富裕空间在右侧
      •End 所有子元素在盒子右侧显示,富裕空间在左侧
      •Center 所有子元素居中
      •Justify 富余空间在子元素之间平均分布
     
  • 相关阅读:
    FilterLog代码分析
    Session
    关于XML的技术详情----XML定义 用途 工作原理及未来
    javaee思维导图
    互联网应用与企业级应用的区别
    javaee课程目标
    Recycle -- 项目总结
    python3.6学习笔记2基础语法
    python3.6学习笔记1认识python
    CentOS6.5下Virtualenv搭建Python3开发环境
  • 原文地址:https://www.cnblogs.com/LO-ME/p/3941077.html
Copyright © 2011-2022 走看看