前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >display:flex

display:flex

作者头像
贵哥的编程之路
发布2020-10-28 15:50:38
1.1K0
发布2020-10-28 15:50:38
举报
文章被收录于专栏:用户7873631的专栏
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		*{padding: 0px;margin: 0px;}
		ul
		{
			list-style: none;
			width: 600px;
			border: 1px solid red;
			margin: 100px auto;
			display: flex;
		}
		ul>li
		{
			width: 100px;
			height: 100px;
			line-height: 100px;
			text-align: center;
			font-size: 30px;
			background: red;
		}
		ul>li:nth-child(2)
		{
			background: green;
		}
		ul>li:nth-child(3)
		{
			background: blue;
		}
	</style>
</head>
<body>
	<ul>
		<li>1</li>
		<li>2</li>
		<li>3</li>
	</ul>
</body>
</html>
在这里插入图片描述
在这里插入图片描述
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		/*默认情况下,主轴是水平方向的,默认是从左到右的排列的.
		但是可以通过属性来修改.
		flex-direction
		属性值有:;
		 row:默认的,从左到右的排列;
		 row-reverse:与row相反的,起点在右边,终点在左边 从右至左的排版;
		 column:起点在顶部,终点在底部从上至下的排版;
		 column-reverse:相反的,起点在底部,终点在顶部,从下至上的排版;
		*/
		*{padding: 0px;margin: 0px;}
		ul
		{
			list-style: none;
			width: 600px;
			border: 1px solid red;
			margin: 100px auto;
			display: flex;
			flex-direction: column-reverse;

		}
		 ul>li{
            width: 100px;
            height: 100px;
            line-height: 100px;
            text-align: center;
            font-size: 30px;
            background: red;
        }
        ul>li:nth-child(2){
            background: green;
        }
        ul>li:nth-child(3){
            background: blue;
        }
	</style>
</head>
<body>
	<ul>
		<li>1</li>
		<li>2</li>
		<li>3</li>
	</ul>
</body>
</html>
在这里插入图片描述
在这里插入图片描述
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		/*默认情况下,主轴是水平方向的,默认是从左到右的排列的.
		但是可以通过属性来修改.
		flex-direction
		属性值有:;
		 row:默认的,从左到右的排列;
		 row-reverse:与row相反的,起点在右边,终点在左边 从右至左的排版;
		 column:起点在顶部,终点在底部从上至下的排版;
		 column-reverse:相反的,起点在底部,终点在顶部,从下至上的排版;
		*/
		*{padding: 0px;margin: 0px;}
		ul
		{
			list-style: none;
			width: 600px;
			border: 1px solid red;
			margin: 100px auto;
			display: flex;
			/*justify-content: flex-start; 主轴上伸缩项对齐的默认值
            注意点: 在设置对齐方式的时候一定要理解两步操作
            1.按照主轴起点对伸缩项进行排版
            2.按照指定的对齐方式对齐排版好的伸缩项
            */
           flex-direction: row;
           /*justify-content: flex-start;/*默认的*/
          /* justify-content: flex-end;/*主轴方向是默认的,然后是对齐方式是到end的地方左往右的对齐把.*/
			/*justify-content: center;/*左往右,center在中间*/
			/*justify-content: space-between;/*是元素与元素的中间有空格.用所有空间的减去所有元素的宽,在除以2就是每一个空格的宽度了*/
			justify-content: space-around;/*是开始与结束都有空格,是中间空格的1/2*/
		}
		 ul>li{
            width: 100px;
            height: 100px;
            line-height: 100px;
            text-align: center;
            font-size: 30px;
            background: red;
        }
        ul>li:nth-child(2){
            background: green;
        }
        ul>li:nth-child(3){
            background: blue;
        }
	</style>
</head>
<body>
	<ul>
		<li>1</li>
		<li>2</li>
		<li>3</li>
	</ul>
</body>
</html>
在这里插入图片描述
在这里插入图片描述
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/08/15 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档