博客列表 >双飞翼布局-20180328-15:26

双飞翼布局-20180328-15:26

AsNwds_MIS王的博客
AsNwds_MIS王的博客原创
2018年03月28日 15:51:42491浏览

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>双飞翼</title>
	<style type="text/css">
	.body{
		width: 100%;
	}
		.top{
			width: 100%;
			height: 50px;
			background-color: grey;
			/*position: fixed;*/
		}

		.both{
			min-width: 1000px;  /*主体宽度*/
			margin: auto; 	/*水平居中*/
			overflow: hidden; 	/*清除浮动*/
			background-color: yellow;
		}
		.main{
			width: 100%;
			background-color: black;
			float: left;  /*向左浮动,脱离文档流*/

		}
		.content{
			height: 600px;
		
			background-color: purple;

			margin:0 200px;  /*给左侧留200边距*/

		}



		.left{
			width: 200px;
			height: 600px;
			
			float: left; /*设置浮动 左和右在主体下面并列一排, */
			
			margin-left: -100%;  /*上面留出200px空间,回到上边*/	
			background-color: green;
		}
		.right{
			width: 200px;
			height: 600px;
			background-color: red;
			float: left; /* 此时块在left正下方*/
			margin-left: -200px; /* 主体右侧 */
		}

		.bottom{
			width: 100%;
			height: 50px;
			background-color: grey;
			clear: both; /* 清除左右两边的浮动元素*/
		/*	position: fixed;*/
		}
	</style>
</head>
<body>
	<div class="top">顶部</div>
	<div class="both">
		<div class="main">
			<div class="content">主体</div>
		</div>
		<div class="left">左侧</div>
		<div class="right">右侧</div>
		
	</div>
	<div class="bottom">底部</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

双飞翼布局主要是 两边定宽,中间自适应的三栏布局

具体实现思路如下:

1、设定上 下 左 右 的大小、高度、各自背景色
2、使用float 浮动
3、通过 margin-left 使左 右 回到正确的位置
4、最后margin-left margin-right 使主体左 右 两边各留出200的宽度

摸索一下午,有可能会跟在想法上会有不一样的 大家留言,谢谢。

双飞翼效果图.jpg微信图片_20180328154447.jpg

上一条:基于约束的SQL攻击下一条:328作业
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议