HTML5页面布局

1,图文混排布局
   img {float: right;}p {font-size: 32px;}
<div class="sec"><img src="penguin.png" alt="penguin"><p>With no change in the rule, the more you grow the more envious you be123  123132312...</p>
</div>

2,题图文字布   
    .sec {background: #EEEEEE;padding: 90px 50px 30px;margin-top: 150px;position: relative;border-top: 10px solid #399;}img {margin-top: -220px;}p {font-size: 32px;}<div class="sec"><img src="penguin.png" alt="penguin"><p>With no change in the rule, the more you grow the more envious you be...</p>
</div>

3,Hero Unit 图标题文混排
.description{width:980px;height:380px;background:#F39C12;text-align: center;padding: 45px 60px;box-sizing: border-box;
}
h1{color: #FFFFFF;margin:15px auto;font-size: 56px;
}
p{color:rgba(255,255,255,.7);
}<div class="description"><img src="comment.png" alt="comment"><h1>Lioness of Gir</h1><p>Monkeys swing merrily from tree to tree. Deer, wild, boars, and antelopes roam freely among the clump of trees. If you were to go deep into the fores5, you might even see a majestic lion, stalking its prey. This is the Gir forest in Gujarat, the only reserve forest in Asia where you can still see the king of the forest walking around.</p>
</div>

 

.description{width:980px;height:380px;background:#F39C12;text-align: center;padding: 45px 60px;box-sizing: border-box;position: relative;
}
img, .content {position: absolute;top:50%;transform: translateY(-50%);
}
img {  left:10%;}
.content{left:30%;width: 60%;
}
h1{color: #FFFFFF;margin:15px auto;font-size: 56px;
}
p{color:rgba(255,255,255,.7);
}<img src="comment.png" alt="comment"><div class="content"><h1>Lioness of Gir</h1><p>Monkeys swing merrily from tree to tree. Deer, wild, boars, and antelopes roam freely among the clump of trees. If you were to go deep into the fores5, you might even see a majestic lion, stalking its prey. This is the Gir forest in Gujarat, the only reserve forest in Asia where you can still see the king of the forest walking around.</p></div>

  

4,两列均分布局

{margin: 0;padding: 0;}section {width: 980px;background: #f5f5f5;box-shadow: 0 0 1px rgba(0, 0, 0, .3) inset;box-sizing: border-box;padding: 40px;}article {width: 49%;float: left;position: relative;}article:nth-child(2) {margin-left: 2%;}h1 {font-size: 32px;margin-bottom: 15px;}p {font-size: 15px;color: #777777;}h1, p{width: 65%;margin-left:35%;}img {position: absolute;top: 0;}.clearfix:before, .clearfix:after {content: "";display: table;}.clearfix:after {clear: both;}<section class="clearfix"><article><h1>Rip Van winkle</h1><p>Many years ago, at the foothills of the Kaatskill (Kat-skill) mountains, was a little village. In the villagelived a simple, good-natured fellow named Rip Van Winkle. He was a kind neighbour, ready to helpanyone. </p><img src="head1.png" alt="picture of Rip Van winkle"></article><article><h1>Robinson Crusoe</h1><p>As Rip and his companion reached them, they stopped playing and stared at Rip with a fixed gaze. Rip wasreally frightened. His companion emptied the contents of the barrel into glasses and made Rip drink it.</p><img src="head2.png" alt="picture of Rip Van winkle"></article>
</section>

 

5,格子布局
  section {width: 500px;background: #FFF;}article {box-sizing: border-box;width: 250px;height: 250px;padding: 20px;text-align: center;float: left;border-bottom: 1px solid rgba(0, 0, 0, .2);border-right: 1px solid rgba(0, 0, 0, .2);}article:nth-child(odd){border-left: 1px solid rgba(0, 0, 0, .2);}article:nth-child(-n+2){border-top: 1px solid rgba(0, 0, 0, .2);}article:nth-child(2) {height: 500px;padding-top: 150px;}article:nth-child(3) {margin-top: -250px;}article h1 {font-size: 32px;margin:10px 0 ;color :#666666;}article P {font-size: 15px;margin-bottom:10px;color:#999;}<section><article><h1>Ulysses</h1><p>Soaring through the galaxies</p><img src="pic1.png" alt="image of Ulysses"></article><article><h1>Dallas</h1><p>Rollin' down to Dallas</p><img src="pic2.png" alt="image of Dallas"></article><article><h1>McKay</h1><p>McKay and his best friend</p><img src="pic3.png" alt="image of McKay"></article>
</section>

  

6,多列等高布局
body {margin:50px;font-family:'Helvetica Neue';font-size:24px;line-height:1.5;
}
#container{width:100%;overflow: hidden;
}
.col{width:33.33%;float:left;text-align:center;box-sizing:border-box;padding:20px;color:#FFF;background:#2980B9;padding-bottom: 500px; /*使用内边距高度增加500px*/margin-bottom: -500px;/*利用负margin抵消增加的500px*/
}
.col img{width:30%;margin-top:30px;
}
.col:nth-child(2){background:#3498DB;
}
.col:nth-child(3){background:#67aeef;
}<div id="container"><div class="col"><img src="trend.png"><h1>Trend</h1><p>The tool refers to periodic trends for collecting and analyzing weak signals and trends in chemistry.</p></div><div class="col"><img src="user.png"><h1>User</h1><p>User namespaces are now fully implemented as of document is obsolete.</p></div><div class="col"><img src="picture.png"><h1>Picture</h1><p>Taking good pictures is something anyone can do with any camera, if you practice enough and avoid some common mistakes..</p></div>
</div>

7,两列自适应布局     左侧固定右侧自适应
* {margin: 0;padding: 0;}body {margin: 50px;}.row {width: 100%;background: #000;position: relative;padding-left: 300px;box-sizing: border-box;}.side {position: absolute;left: 0;width: 300px;height: 500px;background: #c0392B;padding: 50px;}.main {width: 100%;height: 500px;background: #E74C3C;padding: 100px;}.side, .main {text-align: center;font-family: "Comic Sans MS",cursive;color: #fff;box-sizing: border-box;}.main h1 {font-size: 82px;}.main p {font-size: 26px;}.side button {background: #F39C12;border:none;border-radius: 4px;padding:5px 40px;margin-top:30px;font-size: 18px;}<div class="row"><div class="side"><img src="side.png" alt="order"><p>In restaurants, pizza can be baked in an oven with stone bricks above the heat source, an electric deck oven,a conveyor belt oven or a wood- or coal-fired brick oven.</p><button>Order</button></div><div class="main"><img src="pizza.png" alt="pizza"><h1>Pizza</h1><p>Various types of ovens are used to cook them and many varieties exist.</p></div>

8,三列自适应布局

左右固定,中间自适应(圣杯布局)

  

body {margin:50px;min-width:950px;
}
#container {padding-left: 350px;padding-right:250px;
}
#left {background: #16A085;width:350px;margin-left: -100%;position: relative;right: 350px;
}
#main {background: #1ABC9C;width: 100%;
}#right {background: #14856d;width: 250px;margin-right: -250px;}.col {float: left;height: 500px;color: #FFFFFF;font-family:Georgia,"Times New Roman",Times,Serif;font-size: 23px;line-height: 1.5;padding:30px 50px;box-sizing: border-box;}
.col img {float: left;margin: 20px;
}<div id="container"><div id="main" class="col"><img src="star.png"><p>Ramalinga as usual was walking into the Bhuvana Vijayam premises and the guards stopped him. He questioned why were they blocking the way. The soldiers told Ramalinga about the line and asked him to enter the premises only after reciting the first three lines for the last line they recited to him. Ramalinga boiled and trembled with anger on those soldiers. </p></div><div id="left" class="col"><img src="drink.png"><p>Long before guards could understand the meaning of the poem, Ramalinga walked stiff into the main court hall. This state of affairs brought Ramalinga more close to Rayalu.</p></div><div id="right" class="col"><img src="closed.png"><p>Rayalu clapped in all praise of Ramalinga for his ingenuity and wit filled narration. </p></div>
</div>

圣杯布局

body {background:#FFF;margin:50px;min-width:950px;font-family:Georgia, "Times New Roman", Times, serif;font-size:23px;line-height:1.5;}#container{width:100%;color:#FFF;}#left{background:#16A085;width:350px;margin-left:-100%;}#main{background:#1ABC9C;width:100%;height:500px;}#right{background:#14856d;width:250px;margin-left: -250px;}#content{margin:0 250px 0 350px;}.col{text-align:left;padding:30px 50px;box-sizing:border-box;float:left;height:500px;}.col img{float:left;margin:20px;}<div id="container"><div id="main" class="col"><div id="content"><img src="star.png"><p>Ramalinga as usual was walking into the Bhuvana Vijayam premises and the guards stopped him. He questioned why were they blocking the way. The soldiers told Ramalinga about the line and asked him to enter the premises only after reciting the first three lines for the last line they recited to him. Ramalinga boiled and trembled with anger on those soldiers. </p></div></div><div id="left" class="col"><img src="drink.png"><p>Long before guards could understand the meaning of the poem, Ramalinga walked stiff into the main court hall. This state of affairs brought Ramalinga more close to Rayalu.</p></div><div id="right" class="col"><img src="closed.png"><p>Rayalu clapped in all praise of Ramalinga for his ingenuity and wit filled narration. </p></div>
</div>

 

 双飞翼布局和圣杯布局的实现效果完全一样,不同在于圣杯布局需要修改父元素的padding值,而双飞翼布局可以回避掉padding设置,改为使用margin值,在低版本浏览器能够避免一些额外的hack代码。双飞翼的缺点是在页面添加了一项额外的DOM层级。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/521810.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python异常机制

当代码出现异常后底下代码都不会被执行了&#xff0c;也就是程序崩溃了。当然能避免异常的话尽量避免但是有的时候这个是没有办法避免的。 异常处理 &#xff08;注&#xff1a;异常处理是从上往下处理&#xff0c;所以编写代码时要注意&#xff09; 语法 try:可能出现异常…

禁止使用搜索引擎,你了解吗?

员工A&#xff1a;“我今天想搜索的时候&#xff0c;用不了浏览器了&#xff0c;你能用么&#xff1f;” 员工B&#xff1a;“不知道啊我试一下啊” “也不行” 员工C&#xff1a;“为什么啊&#xff1f;” 针对上述对话&#xff0c;我们不禁思考&#xff1a; 公司为什么禁…

典型汽车车灯芯片方案都有哪些?

典型汽车车灯芯片方案主要有先boost升压&#xff0c;再多路buck恒流的灯驱解决方案。如果客户负载比较小&#xff0c;则推荐集成单相boost2路buck与一体的灯驱&#xff0c;如果负载大并且灯的种类比较多&#xff0c;可以把灯驱并联。同时&#xff0c;客户也可以考虑多相boost和…

由于找不到ffmpeg.dll无法执行程序如何修复,分享5种修复方法

ffmpeg.dll的丢失及其对我们日常使用计算机产生的严重影响。想象一下&#xff0c;当你正准备享受一部电影&#xff0c;或是编辑一段珍贵的家庭录像时&#xff0c;电脑突然弹出一个错误提示&#xff1a;“找不到ffmpeg.dll”。那么&#xff0c;ffmpeg.dll文件究竟是什么&#xf…

javaSE-----继承和多态

目录 一.初识继承&#xff1a; 1.1什么是继承&#xff0c;为什么需要继承&#xff1a; 1.2继承的概念与语法&#xff1a; 二.成员的访问&#xff1a; 2.1super关键字 2.2this和super的区别&#xff1a; 三.再谈初始化: 小结&#xff1a; 四.初识多态&#xff1a; 4.1多…

windows部署腾讯tmagic-editor01-Hello world

之前写过一篇使用yarn实现的https://blog.csdn.net/qq_36437991/article/details/133644558&#xff0c;后面的两个没有写&#xff0c;这次准备重新实现 环境 pnpm 8.15.1 node 18.19.0 创建vue项目 pnpm create vitecd hello-world pnpm install执行pnpm dev启动项目 安…

构建高效Web应用:Flask、Django和FastAPI的全面对比

构建高效Web应用&#xff1a;Flask、Django和FastAPI的全面对比 介绍Flask简介快速入门路由和视图函数模板渲染数据库操作Flask项目实战 Django简介快速入门模型和数据库视图和模板表单处理Django项目实战 FastAPI简介快速入门路径操作和参数请求和响应依赖注入FastAPI项目实战…

力扣面试经典150 —— 6-10题

力扣面试经典150题在 VScode 中安装 LeetCode 插件即可使用 VScode 刷题&#xff0c;安装 Debug LeetCode 插件可以免费 debug本文使用 python 语言解题&#xff0c;文中 “数组” 通常指 python 列表&#xff1b;文中 “指针” 通常指 python 列表索引 文章目录 6. [中等] 轮转…

Trans论文复现:考虑源荷不平衡性的微电网鲁棒定价方法程序代码!

适用平台&#xff1a;MatlabYalmipCplex/Gurobi 程序针对目前微电网中高比例新能源发电的波动性和间歇性&#xff0c;提出了考虑源荷不平衡特性的微电网鲁棒定价方法&#xff0c;综合考虑电力市场边际收益和边际成本&#xff0c;利用价格波动来平衡电源和负荷。程序算例丰富、注…

IDEA自带 .http 请求工具文档

基础语法 请求格式 基础格式 Method Request-URI HTTP-Version Header-field: Header-valueRequest-Body其中&#xff0c;GET 请求可以省略 Method 不写&#xff1b;HTTP-Version 可以省略不写&#xff0c;默认使用 1.1 版本。 示例&#xff1a; GET https://www.baidu.co…

浅谈去耦电容的作用、选择、布局及其它电容的区别!

在一些文章资料中&#xff0c;去耦电容器被认为是旁路电容器。在其他资料中&#xff0c;去耦电容和旁路电容的区别在于&#xff1a;“旁路电容以输入信号中的干扰为滤波对象&#xff0c;而去耦电容以输出信号的干扰为滤波对象&#xff0c;防止干扰信号返回到输出端。”力量。”…

[密码学]入门篇——加密方式

一、概述 加密方法主要分为两大类&#xff1a; 单钥加密&#xff08;private key cryptography&#xff09;&#xff1a;加密和解密过程都用同一套密码双钥加密&#xff08;public key cryptography&#xff09;&#xff1a;加密和解密过程用的是两套密码 历史上&#xff0c…