Web前端之路首页投稿(暂停使用,暂停投稿)程序员

CSS3复习整理(box-sizing,column,flex,

2016-04-28  本文已影响494人  Beginning丶2015
nav {
    display: inline-block;
    vertical-align: top;
    width: 25%;
    border: 1px solid yellowgreen;
}
.column {
    display: inline-block;
    vertical-align: top;
    width: 74%;
    border: 1px solid #66BAB7;
}

更多display

.box {
    float: left;
    width: 200px;
    height: 100px;
    margin: 1em;
    border: 1px solid #66BAB7;
}
.after-box {
    clear: left;/*left和both都可以*/
    border: 1px solid yellowgreen;
}

http://zh.learnlayout.com/clearfix.html
清除浮动水很深
.three-column{
    border: 1px solid #66BAB7;
    padding: 1em;
    -webkit-column-count: 3;
    column-count: 3;
    -webkit-column-gap: 1em;
    column-gap: 1em;
}
大概这么个效果
/*此时内边距和边框都不会增加它的宽度*/
.simple {
    width: 500px;
    margin: 20px auto;
    border: 1px solid blue;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
.fancy {
    width: 500px;
    margin: 20px auto;
    padding: 50px;
    border: 10px solid blue;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
  1. 简单的 flex 布局


.container {
    display: -webkit-flex;
    display: flex;
    background: lightblue;
}
nav {
    width: 200px;
    background: #66BAB7;
}
.flex-column {
    flex: 1;
    -webkit-flex: 1;
    background: yellowgreen;
}
  1. 复杂的 flex 布局


.container {
    display: flex;
    display: -webkit-flex;
}
.first {
    flex: initial;
    -webkit-flex: initial;
    width: 200px;
    min-width: 100px;
    background: red;
}
.none {
    flex: none;
    -webkit-flex: none;
    width: 200px;
    background: yellow;
}
.flex1 {
    flex: 1;
    -webkit-flex: 1;
    background: yellowgreen;
}
.flex2 {
    flex: 2;
    -webkit-flex: 2;
    background: #66BAB7;
}
  1. 居中 flex 布局


.vertical-container {
    height: 500px;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
}
.div {
    width: 200px;
    height: 200px;
    border: 10px solid #66BAB7;
}

安利:http://zh.learnlayout.com/toc.html

上一篇下一篇

猜你喜欢

热点阅读