HTML5页面布局

news2024/9/23 3:19:37
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 village
            lived a simple, good-natured fellow named Rip Van Winkle. He was a kind neighbour, ready to help
            anyone. </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 was
            really 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.coloradmin.cn/o/1502940.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

安全测试工具Burpsuit和OWASP ZAP使用入门指南

Burpsuit使用入门指南 安装&#xff1a; 网上有很多相关相关保姆级别教程&#xff0c;所以这里不加赘述了尽量使用java8版本&#xff0c;破解版兼容8做的比较好如果发现注册机无法打开或者能打开注册机【run】无法点击唤起软件安装&#xff0c;可以使用命令行工具 java -jar …

JavaScript 实现飞机大战

文章目录 一些关键点概览&#xff1a;核心模块的具体实现示例&#xff1a;飞机类&#xff08;Plane&#xff09;的基本结构&#xff1a;子弹类&#xff08;Bullet&#xff09;的基本结构&#xff1a;敌机类&#xff08;Enemy&#xff09;的基本结构&#xff1a; 基于前面定义的…

膜厚测量仪在半导体应用中及其重要

随着科技的不断发展&#xff0c;半导体行业已成为当今世界的核心产业之一。在这个领域中&#xff0c;半导体膜厚测量仪作为关键设备&#xff0c;其精度和可靠性对于产品质量和生产效率具有至关重要的作用。本文将详细介绍半导体膜厚测量仪的工作原理、应用领域以及其在半导体制…

SpringMVC04、Controller 及 RestFul

4、Controller 及 RestFul 4.1、控制器Controller 控制器复杂提供访问应用程序的行为&#xff0c;通常通过接口定义或注解定义两种方法实现。控制器负责解析用户的请求并将其转换为一个模型。在Spring MVC中一个控制器类可以包含多个方法在Spring MVC中&#xff0c;对于Contr…

GSM8K数据集分享

来源: AINLPer公众号&#xff08;每日干货分享&#xff01;&#xff01;&#xff09; 编辑: ShuYini 校稿: ShuYini 时间: 2024-3-3 先进的语言模型可以在许多任务上与人类表现相媲美&#xff0c;但它们仍然难以执行多步骤数学推理任务。为此OpenAI团队创建了一个高质量、语言多…

Midjourney绘图欣赏系列(八)

Midjourney介绍 Midjourney 是生成式人工智能的一个很好的例子&#xff0c;它根据文本提示创建图像。它与 Dall-E 和 Stable Diffusion 一起成为最流行的 AI 艺术创作工具之一。与竞争对手不同&#xff0c;Midjourney 是自筹资金且闭源的&#xff0c;因此确切了解其幕后内容尚不…

如何通过四维轻云SDK开发打造智慧景区管理平台?

智慧景区管理平台通常是基于GIS技术&#xff0c;在三维实景地图的基础上&#xff0c;接入景区各类传感设备、第三方系统数据&#xff0c;进行业务功能的梳理及开发。但对于没有GIS开发经验的团队而言&#xff0c;地图开发具有一定的技术门槛&#xff0c;尤其是需要在前端解决好…

使用Revman绘制森林图教程

一 打开Revman 软件 mac 版打开界面如下&#xff0c;叉掉 welcome 点击左上角新文件图标 next——》 填写标题 第一项是针对什么健康问题的什么研究 第二项是什么和什么针对什么问题的比较研究 第三项是针对什么专题的什么健康问题的什么研究 第四项是自定义标…

Java 的 System 类常用方法介绍

Java 中的 System 类是一个final类&#xff0c;它提供了与系统相关的属性和方法。它是一个内置的类&#xff0c;可以直接使用&#xff0c;不需要实例化。System 类提供了标准输入、标准输出和错误输出流&#xff0c;以及对外部定义的属性和系统环境的访问。下面是 System 类的一…

C.C语言分支和循环语句

文章目录 一. 什么是语句 二. 分支语句&#xff08;选择结构&#xff09; 2.1. if 语句 2.1.1. 语法结构 2.1.2. 悬空else 2.1.3. 书写形式的对比 2.1.4. 练习 2.2. switch 语句 3.2.1. 语法结构 3.2.2. 在switch语句中的 break 3.2.3. default子句 3.2.4. 练习 三…

电动机工作原理图

电机&#xff08;俗称“马达”&#xff09;是指依据电磁感应定律实现电能转换或传递的一种电磁装置。它的主要作用是产生驱动转矩&#xff0c;作为用电器或各种机械的动力源。 电动机&#xff0c;转子置于旋转磁场中&#xff0c;在旋转磁场的作用下&#xff0c;获得一个转动力…

本金1w+能做好电商吗?可以做什么平台?

我是电商珠珠 有的小伙伴想要做电商&#xff0c;但是害怕风险太高。眼看着别人的店铺都做起来了&#xff0c;自己还不知道选哪个平台入驻。自己准备1w的本金&#xff0c;也不了解各个平台的入驻机制是怎么样的&#xff0c;什么平台更适合像自己一样的新手小白。 我做电商已经…

苹果cms模板保护设置,防止被扒

苹果cms模板保护设置&#xff0c;防止被扒 如今互联网时代&#xff0c;网站模板前端被扒是常有的事&#xff0c;如何防止模板数据被扒&#xff1f; 保护设置方法&#xff1a; 登录宝塔 找到安装模板的网站 设置禁止访问文件 方法参考截图后缀填&#xff1a;php|html 目录填&a…

【Redis知识点总结】(二)——Redis高性能IO模型剖析

Redis知识点总结&#xff08;二&#xff09;——Redis高性能IO模型及其事件驱动框架剖析 IO多路复用传统的阻塞式IO同步非阻塞IOIO多路复用机制 Redis的IO模型Redis的事件驱动框架 IO多路复用 Redis的高性能的秘密&#xff0c;在于它底层使用了IO多路复用这种高性能的网络IO&a…

【Unity】Tag、Layer、LayerMask

文章目录 层&#xff08;Layer&#xff09;什么是LayerLayer的应用场景Layer层的配置&#xff08;Tags & Layers&#xff09;Layer的数据结构LayerMaskLayer的选中和忽略Layer的管理&#xff08;架构思路&#xff09;层碰撞矩阵设置&#xff08;Layer Collision Matrix&…

自动化测试框架(全)

&#x1f345; 视频学习&#xff1a;文末有免费的配套视频可观看 &#x1f345; 点击文末小卡片&#xff0c;免费获取软件测试全套资料&#xff0c;资料在手&#xff0c;涨薪更快 无论是在自动化测试实践&#xff0c;还是日常交流中&#xff0c;经常听到一个词&#xff1a;框架…

java日志-干货系列-拒绝长篇大论

一、java日志系统架构图 二、架构图解释 日志框架&#xff1a;日志框架相较于门面是先出现的&#xff0c;因此日志框架本身就可以单独使用的&#xff0c;并不需要日志门面。 日志门面&#xff1a;简单点说就是统一了操作日志的api&#xff0c;然应用层无需关心底层的日志框架…

基于Java的物管系统设计与实现

目 录 摘 要 I Abstract II 引 言 1 1 相关技术介绍 3 1.1 JSP介绍 3 1.2 MySQL介绍 3 1.3 B/S开发模式 3 1.4 Java介绍 4 2 系统分析 5 2.1 可行性研究 5 2.1.1技术可行性 5 2.2.2经济可行性 5 2.3.1操作可行性 5 2.2 需求分析 6 2.2.1系统用例图 6 2.2.2系统功能模块需求分析…

什么是微隔离技术?

微隔离产生的背景 首先来看下南北向流量以及东西向流量的含义 南北向流量 指通过网关进出数据中心的流量&#xff0c;在云计算数据中心&#xff0c;处于用户业务虚拟机&#xff08;容器&#xff09;跟外部网络之间的流量&#xff0c;一般来说防火墙等安全设备部署在数…

基于Springboot的智慧社区居家养老健康管理系统(有报告)。Javaee项目,springboot项目。

演示视频&#xff1a; 基于Springboot的智慧社区居家养老健康管理系统&#xff08;有报告&#xff09;。Javaee项目&#xff0c;springboot项目。 项目介绍&#xff1a; 采用M&#xff08;model&#xff09;V&#xff08;view&#xff09;C&#xff08;controller&#xff09;…