日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

css左側 div給固定寬 右側div自適應

作者:Mr_wuying 更新時間: 2022-04-11 編程語言
	<div class="left">div>
	<div class="right">div>

在這里插入圖片描述

第一種 浮動

.left{
	width: 200px;
	float: left;
	height: 200px;
	background: #0000FF;
	
}
.right{
	margin-left: 200px;
	height: 200px;
	background: #00FF00;
}

弟二種 計算屬性

.left{
	width: 200px;
		float: left;
		height: 200px;
		background: #0000FF;
		
	}
.right{
	width: calc(100% - 200px);
	height: 200px;
	float: right;
	background: #00FF00;
}

第三種 flex

body,html{
	width:100%;
	display: flex;
}
.left{
	flex: 0 0 200px;
	height: 200px;
	background: #0000FF;
	
}
.right{
	flex: 1;
	height: 200px;
	background: #00FF00;
}

flex:flex-grow、flex-shrink 、flex-basis
flex-grow為0,則存在剩余空間也不放大
flex-shrink為1,則空間不足該項目縮小
flex-basis為auto,則該項目本來的大小

原文鏈接:https://blog.csdn.net/j244233138/article/details/110139777

欄目分類
最近更新