css3 flexbox 示例
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> .flex-box { margin: 2em; border: 1px solid #ccc; height: 100px; width: 400px; display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row; /* row, row-reverse, column, column-reverse */ } .flex-item { min-width: 100px; min-height: 100px; color: #fff; font-weight: bold; font-family: arial; } .item-1 { background: green; } .item-2 { background: red; } .item-3 { background: blue; } #flex-box-1 { -webkit-justify-content: flex-start; justify-content: flex-start; } #flex-box-2 { -webkit-justify-content: flex-end; justify-content: flex-end; } #flex-box-3 { -webkit-justify-content: center; justify-content: center; } #flex-box-4 { -webkit-justify-content: space-between; justify-content: space-between; } #flex-box-5 { -webkit-justify-content: space-around; justify-content: space-around; } </style> </head> <body> Flex-start: <div id="flex-box-1" class="flex-box"> <div class="flex-item item-1">1</div> <div class="flex-item item-2">2</div> <div class="flex-item item-3">3</div> </div> Flex-end: <div id="flex-box-2" class="flex-box"> <div class="flex-item item-1">1</div> <div class="flex-item item-2">2</div> <div class="flex-item item-3">3</div> </div> Center: <div id="flex-box-3" class="flex-box"> <div class="flex-item item-1">1</div> <div class="flex-item item-2">2</div> <div class="flex-item item-3">3</div> </div> Space-between: <div id="flex-box-4" class="flex-box"> <div class="flex-item item-1">1</div> <div class="flex-item item-2">2</div> <div class="flex-item item-3">3</div> </div> Space-around: <div id="flex-box-5" class="flex-box"> <div class="flex-item item-1">1</div> <div class="flex-item item-2">2</div> <div class="flex-item item-3">3</div> </div> </body> </html>
相关推荐
GeolageWu 2019-06-30
zhanghao 2020-06-16
tichangde 2020-05-19
xsgnzb 2020-03-09
lixiaotao 2020-03-02
bertzhang 2019-12-25
RexLeee 2019-12-23
MaureenChen 2019-12-03
wangjie 2019-11-10
谢恩铭 2016-01-10
时间猎人 2019-09-06
Jolestar 2016-06-02
gigipop 2019-07-01
标题 2019-07-01
jianqi 2019-07-01
RLanffy 2019-07-01
VVVinegar 2019-07-01
CoderChang 2019-06-30