博主信息
博文 34
粉丝 2
评论 2
访问量 28284
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
双飞翼布局-20180328-15:26
AsNwds_MIS王的博客
原创
669人浏览过

实例

<!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

批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学