CSS --- flexbox弹性盒子布局(不用浮动 一行显示)

 

代码以下~html

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
body{ margin:0;}
.box{ display:flex; height:300px; /* flex-direction:column; 竖方向的 */ /*flex-direction:column-reverse; 竖方向倒过来*/}
.div1{ background:red; flex:1}
.div2{ background:blue; flex:2}

</style>
</head>

<body>
<div class="box">
    <div class="div1">111</div>
    <div class="div2">222</div>
</div>
</body>
</html>
相关文章
相关标签/搜索