圣杯布局

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
padding: 0;
margin: 0;
}
body{
min-width: 550px;
}
.container{
background-color: red;
padding-left: 200px;
padding-right: 150px;
}
.center {
width: 100%;
background-color: green;
float: left;
height: 500px;
}
.left{
width: 200px;
height: 100px;
float: left;
background-color: pink;
margin-left: -100%;
position: relative;
top: 0;
right: 200px;
}
.right{
width: 150px;
background-color: purple;
height: 100px;
float: left;
margin-right: -100%;
}
</style>
</head>
<body>
<div class="container">
<div class="center"></div>
<div class="left"></div>

<div class="right"></div>
</div>
</body>
</html>
主要思想是container中设置pl,pr;包裹left,center,right。全部左浮。其中center宽度设置100%,那么left,和right被挤下去了。left通过利用margin-left:-100%,然后再定位,右移。right通过设置margin-right设置-100%,使其在右边。
记得要给body设置最小宽度。最小宽度为:left和right的宽度加上left右移的距离。
posted @   菜鸟小何  阅读(209)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
点击右上角即可分享
微信分享提示