中间自适应俩边固定

第一种

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			.box div{
				height: 100px;
				position: absolute;
			}
			.box{
				background: blue;
				position: relative;
			}
			.left{
				width: 100px;
				background: red;
				left: 0;
				top: 0;
			}
			.right{
				width: 100px;
				background: green;
				right: 0;
				top: 0;
			}
			.center{
				background: #CCC;
				left: 100px;
				right: 100px;
				top: 0;
			}
		</style>
	</head>
	<body>
		<div class="box">
		  <div class="left">1</div>
		   <div class="center">2</div>
		  <div class="right">3</div>
		</div>
	</body>
</html>

第二种

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			.box{
    			display: flex;
    			background: red;
    			height: 100px;
			}
			.center{
				flex: 1;
    			height: 100px;
    			background: blue;
			}
			.left,.right{
				width: 100px;
			    height: 100px;
			    background: red;
			}
		</style>
	</head>
	<body>
		<div class="box">
		    <div class="left">1</div>
		    <div class="center">2</div>
		    <div class="right">3</div>
		</div>
	</body>
</html>

第三种

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>

			.left,.right{
				width: 100px;
			    height: 100px;
			    background: red;
			}
			.left{
				float: left;
			}
			.right{
				float: right;
			}
			.center{
				margin: 0 100px;
				height: 100px;
				background: blue;
			}
		</style>
	</head>
	<body>

		<div class="left">1</div>

	    <div class="right">3</div>

		<!--注意中间那块在最下面,因为如果放在上面浮动的div就在其下了-->
		<div class="center">2</div>

	</body>
</html>

第四种

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			.left,.center,.right{
				float: left;
    			height: 100px;
			}
			.left,.right{
				width: 200px;
				background-color: red;
			}
			.center{
				width: calc(100% - 400px);
				background: blue;
			}
		</style>
	</head>
	<body>
		<div class="left">1</div>
		<div class="center">2</div>
		<div class="right">3</div>
	</body>
</html>

第五种(双飞翼布局)

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			.d1{
				background: red;
				float: left;
				width: 100%;
				height: 200px;

			}
			.d1 div{
				margin: 0 200px;
				background: yellow;
			}
			.d2{
				background: blue;
				float: left;
				margin-left: -100%;
				width: 200px;
				height: 200px;

			}
			.d3{
				background: green;
				height: 200px;
				width: 200px;
				float: left;
				margin-left: -200px;
			}
		</style>
	</head>
	<body>
		<div class="d1">
			<div>
				111
			</div>
		</div>
		<div class="d2">
			22222
		</div>
		<div class="d3">
			33333
		</div>
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值