<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
padding:0;
margin:0;
}
/*flex里的项目是不脱离文档流的*/
#hd{
width:80%;
border:4px solid orangered;
height:500px;
/*指定容器里的项目为弹性布局*/
display: flex;
/*flex-wrap:wrap;*/
}
#hd>div{
width:180px;
height:200px;
background:dodgerblue;
border:1px solid purple;
font-size:30px;
color:#fff;
text-align:center;
/*比例分配1*/
flex: 1;
}
#hd>div:nth-child(3){
/*比例分配两倍*/
flex: 2;
}
</style>
</head>
<body>
<!-- flex里的项目,总宽度不超过父级元素类似于flaot -->
<!-- flex里的项目,总宽度超过父级元素,那么加给项目的宽度就无效了,每个项目的宽度会自动均分 -->
<div id="hd">
<div>1</div>
<!-- order调整顺序order值为10,其它的值为0 -->
<div style="order:10">2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
padding:0;
margin:0;
}
/*flex里的项目是不脱离文档流的*/
#hd{
width:80%;
border:4px solid orangered;
height:500px;
/*指定容器里的项目为弹性布局*/
display: flex;
/*flex-wrap:wrap;*/
}
#hd>div{
width:180px;
height:200px;
background:dodgerblue;
border:1px solid purple;
font-size:30px;
color:#fff;
text-align:center;
/*比例分配1*/
flex: 1;
}
#hd>div:nth-child(3){
/*比例分配两倍*/
flex: 2;
}
</style>
</head>
<body>
<!-- flex里的项目,总宽度不超过父级元素类似于flaot -->
<!-- flex里的项目,总宽度超过父级元素,那么加给项目的宽度就无效了,每个项目的宽度会自动均分 -->
<div id="hd">
<div>1</div>
<!-- order调整顺序order值为10,其它的值为0 -->
<div style="order:10">2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</body>
</html>