弹性布局多列换行居左布局,flex布局下两端对齐,不满左对齐

news/2024/5/19 17:40:49 标签: flex, html, css

html" title=flex>flex_0">弹性布局多列换行居左布局,html" title=flex>flex布局下两端对齐,不满左对齐

问题情境:

html" title=flex>flex布局下,多行排列,如何让html" title=flex>flex布局最后一行没有排满时,向左对齐排列且与上面的行间距相同

在这里插入图片描述
实现效果:
在这里插入图片描述

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<style type="text/css">
		li {
			list-style: none;
		}

		.List {
			width: 100%;
			box-sizing: border-box;
			display: html" title=flex>flex;
			justify-content: space-between;
			html" title=flex>flex-wrap: wrap;
			padding: 10px;
		}
		.List:after{
			content: "";
			html" title=flex>flex: auto;
		}

		.item {
			/* 宽度是固定好的 */
			width: 220px;
			height: 60px;
			background-color: azure;
			margin-bottom: 10px;
			border: 1px solid red;
			/*这个数值需要自己去调*/
			margin-right: 17px;
		}
		.item:nth-child(5n){
			/* 尽量让item在list中居中,两边都没有margin */
			margin-right: 0;
		}
		
	</style>
	<body>
		<div id="" style="width: 1200px;margin: auto;background-color: #cccccc;height: 500px;">
			<ul class="List">
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				<li class="item"></li>
				
			</ul>
		</div>

	</body>
</html>

重要代码:要加after以及每个item的margin-right

.List:after{
		content: "";
		html" title=flex>flex: auto;
	}

http://www.niftyadmin.cn/n/855371.html

相关文章

vue项目出现问题

vue项目出现问题 1.vueelementUi项目中 饿了么组件上不能直接添加事件&#xff0c;要加上.native <el-card :body-style"{ padding: 0px }" class"singleItem" :style"{width:newItem.itemWidthpx}" click.native"navVideoPlay(newIte…

JS小游戏_能坚持几秒

http://test.douzhao.com/test.htm 规则很简单&#xff1a;移动方块&#xff0c;不要被4个长方形碰到&#xff0c;会加速的。 我只有22.219秒&#xff0c;玩过的人把成绩贴一下吧。 xjyggd22.219 昨晚快睡觉时玩了一下&#xff0c;到24秒了&#xff0c;发现这4个长方形的移动有…

var、let、const在使用中的区别

var、let、const在使用中的区别 此文章非原创文章&#xff0c;是借鉴文章&#xff0c;转载请注意&#xff01;&#xff01;&#xff01; <!DOCTYPE html> <html><head><meta charset"utf-8"><title></title></head><bo…

组件之间传值(父子组件、非父子组件)

组件之间传值&#xff08;父子组件、非父子组件&#xff09; 一、父子组件之间传值 1.父向子传值 &#xff08;1&#xff09;.父组件 父组件里需引用子组件&#xff0c;并传值给子组件&#xff0c;代码如下&#xff1a; <template><div><span>哈哈哈哈<…

Vue实时刷新数组

Vue实时刷新数组 1.第一种&#xff0c;直接拼接数组 <template><div style"border: 1px solid #ccc; width: 500px;height:200px; margin: auto;"><div><button click"addItem" style"float: right;" >添加新的项<…

把SQL查询出来的2个表合并

如果要去重复就用 UNION 如果不去重复就用 UNION ALL select * from A union all select * from B

man和woman的近义词

今日偶然发现了这个网站http://www.similar-word.com/default.asp&#xff0c;挺有自己特色的一个站点。 你可以试着输入man看看 搜索结果 然后再输入woman看看搜索结果。 哈哈&#xff0c;感觉起码这俩词的结果是很准确哦。

nodejs-websocket创建websocket服务器

nodejs-websocket创建websocket服务器 首先&#xff0c;感谢csdn各位大佬们对创建websocket的解释&#xff01; 1.安装模块 npm install nodejs-websocket 2.搭建websocket服务端 这个是一个js文件 //websocket.js // 搭建websocket服务器 const ws require("nodejs-we…