固定两边,中间自适应布局方案

方法一:float解决方案

<section class="layout float">
			<style>
				.layout.float {
					width: 100%;
					height: 100px;
				}

				.layout.float .floatleft-center-right>div {
					height: 100px;
				}

				.floatleft-center-right .left {
					background: red;
					width: 300px;
					float: left;
				}

				.floatleft-center-right .center {
					background: yellow;
				}

				.floatleft-center-right .right {
					background: blue;
					width: 300px;
					float: right;
				}
			</style>
			<article class="floatleft-center-right">
				<div class="left"></div>
				<div class="right"></div>
				<div class="center">
					<p>float解决方案</p>
					<p>float解决方案</p>
					<p>float解决方案</p>
				</div>
			</article>
		</section>

方法二:绝对定位position解决方案

<section class="layout position">
			<style>
				.layout.position {
					width: 100%;
					height: 100px;
					position: relative
				}

				.layout.position .positionleft-center-right>div {
					height: 100px;
					position: absolute;
				}

				.positionleft-center-right .left {
					background: red;
					width: 300px;
					left: 0;
				}

				.positionleft-center-right .center {
					background: yellow;
					left: 300px;
					right: 300px;
				}

				.positionleft-center-right .right {
					background: blue;
					width: 300px;
					right: 0;
				}
			</style>
			<article class="positionleft-center-right">
				<div class="left"></div>
				<div class="center">
					<p>position解决方案</p>
					<p>position解决方案</p>
					<p>position解决方案</p>
				</div>
				<div class="right"></div>
			</article>
		</section>

方法三:flex解决方案

<section class="layout flexbox">
			<style>
				.layout.flexbox {
					width: 100%;
					height: 100px;
				}

				.flexLeft-center-right {
					display: flex;
				}

				.flexLeft-center-right>div {
					height: 100px;
				}

				.flexLeft-center-right .left {
					background: red;
					width: 300px;
				}

				.flexLeft-center-right .center {
					background: yellow;
					flex: 1;
				}

				.flexLeft-center-right .right {
					background: blue;
					width: 300px;
				}
			</style>
			<article class="flexLeft-center-right">
				<div class="left"></div>
				<div class="center">
					<p>flexBox解决方案</p>
					<p>flexBox解决方案</p>
					<p>flexBox解决方案</p>
				</div>
				<div class="right"></div>
			</article>
		</section>

方法四:table解决方案

<section class="layout table">
			<style>
				.layout.table .tableLeft-center-right {
					width: 100%;
					height: 100px;
					display: table;
				}

				.tableLeft-center-right>div {
					display: table-cell;
				}

				.tableLeft-center-right .left {
					background: red;
					width: 300px;
				}

				.tableLeft-center-right .center {
					background: yellow;
				}

				.tableLeft-center-right .right {
					width: 300px;
					background: blue;
				}
			</style>
			<article class="tableLeft-center-right">
				<div class="left"></div>
				<div class="center">
					<p>table解决方案</p>
					<p>table解决方案</p>
					<p>table解决方案</p>
				</div>
				<div class="right"></div>
			</article>
		</section>

方法五:grid解决方案

<section class="layout grid">
			<style media="screen">
				.layout.grid .gridLeft-center-right {
					width: 100%;
					display: grid;
					grid-template-rows: 100px;
					grid-template-columns: 300px auto 300px;
				}
				.gridLeft-center-right .left{
					background: red;
				}
				.gridLeft-center-right .center{
					background: yellow;
				}
				.gridLeft-center-right .right{
					background: blue;
				}
			</style>
			<article class="gridLeft-center-right">
				<div class="left"></div>
				<div class="center">
					<p>grid解决方案</p>
					<p>grid解决方案</p>
					<p>grid解决方案</p>
				</div>
				<div class="right"></div>
			</article>
		</section>

本文摘录自其它博客,详情请点击

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值