<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style> | |
body{ | |
background-color: #eee; | |
} | |
*{ | |
margin:0; | |
padding: 0; | |
list-style: none; | |
} | |
section{ | |
width: 1000px; | |
margin:10px auto; | |
} | |
ul{ | |
background-color: #fff; | |
border: 1px solid red; | |
height: 300px; | |
} | |
li{ | |
width: 150px; | |
height: 150px; | |
background-color: pink; | |
margin:10px; | |
} | |
section:nth-child(1) ul{ | |
/*设置伸缩布局*/ | |
display:flex; | |
/*侧轴对齐方式:从侧轴开始的地方对齐*/ | |
align-items: flex-start; | |
} | |
section:nth-child(2) ul{ | |
/*设置伸缩布局*/ | |
display:flex; | |
/*侧轴对齐方式:从侧轴开始的地方对齐*/ | |
align-items: flex-end; | |
} | |
section:nth-child(3) ul{ | |
/*设置伸缩布局*/ | |
display:flex; | |
/*侧轴对齐方式:从侧轴开始的地方对齐*/ | |
align-items: center; | |
/* 主轴 水平*/ | |
justify-content: center; | |
} | |
section:nth-child(4) ul{ | |
/*设置伸缩布局*/ | |
display:flex; | |
/*侧轴对齐方式:从侧轴开始的地方对齐*/ | |
align-items: stretch; | |
} | |
section:nth-child(4) ul li{ | |
height: auto; | |
} | |
section:nth-child(5) ul{ | |
/*设置伸缩布局*/ | |
display:flex; | |
/*主轴两端对齐*/ | |
justify-content: space-between; | |
/*侧轴居中*/ | |
align-items: center; | |
} | |
</style> | |
</head> | |
<body> | |
<section> | |
<h4>侧轴对齐方式:flex-start</h4> | |
<ul> | |
<li>1</li> | |
<li>2</li> | |
<li>3</li> | |
</ul> | |
</section> | |
<section> | |
<h4>侧轴对齐方式:flex-end</h4> | |
<ul> | |
<li>1</li> | |
<li>2</li> | |
<li>3</li> | |
</ul> | |
</section> | |
<section> | |
<h4>侧轴对齐方式:center</h4> | |
<ul> | |
<li>1</li> | |
<li>2</li> | |
<li>3</li> | |
</ul> | |
</section> | |
<section> | |
<h4>侧轴对齐方式:streach</h4> | |
<ul> | |
<li>1</li> | |
<li>2</li> | |
<li>3</li> | |
</ul> | |
</section> | |
<section> | |
<h4>侧轴对齐方式:演示</h4> | |
<ul> | |
<li>1</li> | |
<li>2</li> | |
</ul> | |
</section> | |
</body> | |
</html> |
新闻热点
疑难解答