一个div靠左另一个靠右

1.使用flex布局

<style>
			#back{
				border: red solid 1px;
				width: 800px;
				height: 500px;
				display: flex;
				align-items: center;
			}
			#left{
				border: blue 1px solid;
				width: 100px;
				height: 100px;
				justify-content: flex-start;
				
				
			}
			#right{
				border: blue 1px solid;
				width: 100px;
				height: 100px;
				justify-content: flex-end;
				flex:1;
				display: flex;
				
			}
		</style>
	</head>
	<body>
		<div id="back">
			<div id="left">left</div>
			<div id="right">right</div>
			
		</div>

2.父容器使用

 display: flex;
  justify-content: space-between;
posted @ 2022-09-19 12:24  lwx_R  阅读(525)  评论(0)    收藏  举报