关于页面的多种自适应布局——两列布局

我们在切页面的时候打交道最多的就是关于布局排版的技巧,我这里总结了一些平时做页面时用的到各种布局技巧,作为笔记便于日后随时查询。

1、简单结构1,列表在前,内容在后

 1 <style type="text/css">
 2 .layout{background-color:gray; padding:10px; border:10px solid orange; margin:10px 0; zoom:1;}
 3 .layout:after{content:"";clear:both; display:block; height:0px; overflow:hidden;}
 4 .wrap{}
 5 .content{background-color:green; /*height:290px;*/}
 6 .sidebar{background-color:blue; /*height:290px;*/ width:200px;}
 7 p{color:#fff;font-family:arial; font-size:16px; line-height:30px;}
 8 p.clear{clear:both;}
 9 /**简单结构1,列表在前,内容在后**/
10 .layout-1{}
11     .layout-1 .sidebar{float:left;}
12     .layout-1 .content{margin-left:210px; _margin-left:207px; /*IE6下的3像素外边距问题*/}
13 .layout-1-1{}
14     .layout-1-1 .sidebar{float:right;}
15     .layout-1-1 .content{margin-right:210px; _margin-right:207px;text-overflow:ellipsis; white-space:nowrap; /*IE6下的3像素外边距问题*/}
16 .layout-2{}
17     .layout-2 .sidebar{float:left; margin-right:10px; _margin-right:7px; /*IE6下的3像素外边距问题*/}
18     .layout-2 .content{overflow:hidden; _zoom:1; /*"overflow" IE6下hasLayout没有起作用,使用zoom:1来实现*/}
19 .layout-2-1{}
20     .layout-2-1 .sidebar{float:right; margin-left:10px; _margin-left:7px; /*IE6下的3像素外边距问题*/}
21     .layout-2-1 .content{overflow:hidden; _zoom:1; /*"overflow" IE6下hasLayout没有起作用,使用zoom:1来实现*/}
22 .layout-3{position:relative;}
23     .layout-3 .sidebar{position:absolute; left:10px; top:10px;}
24     .layout-3 .content{margin-left:210px;}
25 .layout-3-1{position:relative;}
26     .layout-3-1 .sidebar{position:absolute; right:10px; top:10px;}
27     .layout-3-1 .content{margin-right:210px;}
28 </style>
29 
30 <div class="layout layout-1">
31     <div class="sidebar"><p>.layout-1 .sidebar{float:left;}</p></div>
32     <div class="content"><p>.layout-1 .content{margin-left:210px; _margin-left:207px; /*IE6下的3像素外边距问题*/}</p></div>
33     <p>这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
34 </div>
35 <div class="layout layout-1-1">
36     <div class="sidebar"><p>.layout-1-1 .sidebar{float:right;}</p></div>
37     <div class="content"><p>.layout-1-1 .content{margin-right:210px; _margin-right:207px; /*IE6下的3像素外边距问题*/}</p></div>
38     <p class="clear">这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
39 </div>
40 
41 <div class="layout layout-2">
42     <div class="sidebar"><p>.layout-2 .sidebar{float:left; margin-right:10px; _margin-right:7px; /*IE6下的3像素外边距问题*/}</p></div>
43     <div class="content"><p>.layout-2 .content{overflow:hidden; _zoom:1; /*"overflow" IE6下hasLayout没有起作用,使用zoom:1来实现*/}</p></div>
44     <p class="clear">这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
45 </div>
46 <div class="layout layout-2-1">
47     <div class="sidebar"><p>.layout-2-1 .sidebar{float:right; margin-left:10px; _margin-left:7px; /*IE6下的3像素外边距问题*/}</p></div>
48     <div class="content"><p>.layout-2-1 .content{overflow:hidden; _zoom:1; /*"overflow" IE6下hasLayout没有起作用,使用zoom:1来实现*/}</p></div>
49     <p class="clear">这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
50 </div>
51 <div class="layout layout-3">
52     <div class="sidebar"><p>.layout-3 .sidebar{position:absolute; left:10px; top:10px;}</p></div>
53     <div class="content"><p>.layout-3 .content{margin-left:210px;}</p></div>
54     <p class="clear">这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
55 </div>
56 <div class="layout layout-3-1">
57     <div class="sidebar"><p>.layout-3 .sidebar{position:absolute; right:10px; top:10px;}</p></div>
58     <div class="content"><p>.layout-3 .content{margin-right:210px;}</p></div>
59     <p>这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
60 </div>

2、简单结构2,内容在前,列表在后,这种布局兼容性不是很好,内容在前对于SEO优化很重要

 1 <style type="text/css">
 2 .layout{background-color:gray; padding:10px; border:10px solid orange; margin:10px 0; zoom:1;}
 3 .layout:after{content:"";clear:both; display:block; height:0px; overflow:hidden;}
 4 .wrap{}
 5 .content{background-color:green; /*height:290px;*/}
 6 .sidebar{background-color:blue; /*height:290px;*/ width:200px;}
 7 p{color:#fff;font-family:arial; font-size:16px; line-height:30px;}
 8 p.clear{clear:both;}
 9 
10 /**简单结构2,内容在前,列表在后**/
11 .layout-10{}
12     .layout-10 .content{margin-left:210px; margin-bottom:-30px;}
13     .layout-10 .sidebar{}
14 .layout-10-1{}
15     .layout-10-1 .content{margin-right:210px; margin-bottom:-30px;}
16     .layout-10-1 .sidebar{float:right;}
17 .layout-11{position:relative;}
18     .layout-11 .content{margin-left:210px;}
19     .layout-11 .sidebar{position:absolute; left:10px; top:10px;}
20 .layout-11-1{position:relative;}
21     .layout-11-1 .content{margin-right:210px;}
22     .layout-11-1 .sidebar{position:absolute; right:10px; top:10px;}
23 
24 </style>
25 <div class="layout layout-10">
26     <div class="content"><p>.layout-10-1 .content{margin-right:210px; margin-bottom:-30px;/**这里的margin-bottom:-30px;需要通过js来计算,取值为content区的高度,也可以给sidebar:margin-top:-30px;**/}</p></div>
27     <div class="sidebar"><p>.layout-10 .sidebar{}</p></div>
28     <p>这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
29 </div>
30 <div class="layout layout-10-1">
31     <div class="content"><p>.layout-10-1 .content{margin-right:210px;}</p></div>
32     <div class="sidebar"><p>.layout-10-1 .sidebar{float:right; margin-top:-30px;/**这里的margin-top:-30px;需要通过js来计算,取值为content区的高度,也可以给content:margin-bottom:-30px;后边的元素需要清除浮动**/}</p></div>
33     <p class="clear">.layout-10-1 p{clear:both;}<br/>这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
34 </div>
35 
36 <div class="layout layout-11">
37     <div class="content"><p>.layout-11 .content{margin-left:210px;}</p></div>
38     <div class="sidebar"><p>.layout-11 .sidebar{position:absolute; left:10px; top:10px;}</p></div>
39     <p>这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
40 </div>
41 
42 <div class="layout layout-11-1">
43     <div class="content"><p>.layout-11 .content{margin-left:210px;}</p></div>
44     <div class="sidebar"><p>.layout-11 .sidebar{position:absolute; left:10px; top:10px;}</p></div>
45     <p>这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>
46 </div>

3、复杂结构,内容在前,列表在后,能够很好的实现自适应布局,并且兼容性好。内容在前对于SEO优化很重要

  1 <style type="text/css">
  2 .layout{background-color:gray; padding:10px; border:10px solid orange; margin:10px 0; zoom:1;}
  3 .layout:after{content:"";clear:both; display:block; height:0px; overflow:hidden;}
  4 .wrap{}
  5 .content{background-color:green; /*height:290px;*/}
  6 .sidebar{background-color:blue; /*height:290px;*/ width:200px;}
  7 p{color:#fff;font-family:arial; font-size:16px; line-height:30px;}
  8 p.clear{clear:both;}
  9 
 10 /**复杂结构布局**/
 11 .layout-21{}
 12     .layout-21 .wrap{ float:left; width:100%;}
 13     .layout-21 .content{margin-left:210px;}
 14     .layout-21 .sidebar{float:left; margin-left:-100%;}
 15 .layout-22{}
 16     .layout-22 .wrap{float:left; width:100%;}
 17     .layout-22 .content{margin-right:210px;}
 18     .layout-22 .sidebar{float:right; margin-left:-200px;}
 19 .layout-23{}
 20     .layout-23 .wrap{float:left; width:100%; margin-right:-200px;}
 21     .layout-23 .content{margin-right:210px;}
 22     .layout-23 .sidebar{float:left;}
 23 .layout-24{}
 24     .layout-24 .wrap{float:right; width:100%; margin-left:-200px;}
 25     .layout-24 .content{margin-left:210px;}
 26     .layout-24 .sidebar{float:left;}
 27 </style>
 28 <div class="layout layout-21">
 29     <div class="wrap">
 30         <div class="content">
 31             内容区域,左漂浮
 32             <p>
 33                 .layout-21 .wrap{ float:left; width:100%;}<br />
 34                 .layout-21 .content{margin-left:210px;}
 35             </p>
 36         </div>
 37     </div>
 38     <div class="sidebar">
 39         列表区域
 40         <p>
 41             .layout-21 .sidebar{float:left; margin-left:-100%;}
 42         </p>
 43     </div>
 44     <p class="clear">这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p> 
 45 </div>
 46 
 47 <div class="layout layout-22">
 48     <div class="wrap">
 49         <div class="content">
 50             内容区域
 51             <p>
 52                 .layout-22 .wrap{float:left; width:100%;}<br />
 53                 .layout-22 .content{margin-right:210px;}
 54             </p>
 55 
 56         </div>
 57     </div>
 58     <div class="sidebar">
 59         列表区域
 60         <p>
 61         .layout-22 .sidebar{float:right; margin-left:-200px;}
 62         </p>
 63     </div>
 64     <p class="clear">这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p> 
 65 </div>
 66 
 67 <div class="layout layout-23">
 68     <div class="wrap">
 69         <div class="content">
 70             内容区域
 71             <p>
 72                 .layout-23 .wrap{float:left; width:100%; margin-right:-200px;}<br />
 73                 .layout-23 .content{margin-right:210px;}
 74             </p>
 75 
 76         </div>
 77     </div>
 78     <div class="sidebar">
 79         列表区域
 80         <p>
 81         .layout-2 .sidebar{float:left;}
 82         </p>
 83     </div>
 84     <p class="clear">这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p> 
 85 </div>
 86 
 87 <div class="layout layout-24">
 88     <div class="wrap">
 89         <div class="content">
 90             内容区域
 91             <p>
 92                 .layout-24 .wrap{float:left; width:100%;}<br />
 93                 .layout-24 .content{margin-right:210px;}
 94             </p>
 95 
 96         </div>
 97     </div>
 98     <div class="sidebar">
 99         列表区域
100         <p>
101         .layout-24 .sidebar{float:right; margin-left:-200px;}
102         </p>
103     </div>
104     <p class="clear">clear:both<br />这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容</p>   
105 </div>

 

转载于:https://www.cnblogs.com/qwguo/p/9903312.html

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

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

相关文章

很全的sas基础知识

5.1 SAS表达式简介   &#xff11;&#xff0e;SAS常数表达式   (1)数值常数 如: 1.23、 -5、 0.5E-10。   (2)字符常数 如: name1TOME、 name2MARY、name3JOHN。   (3)日期(d)、时间(t)、日时(dt)常数 如: d101JAN80d、t19:25:19t、   dt118JAN80:9:27:05dt。  …

kitti数据集_KITTI数据集激光雷达坐标系下的里程计真值

由KITTI数据集Odometry模块的devkit_odometrydevkitreadme.txt所述&#xff0c;KITII数据集提供里程计的真值是在左相机表坐标系下的&#xff0c;并没有提供激光雷达坐标系下的真值。因此&#xff0c;求得激光雷达坐标系下的真值&#xff0c;对我们使用KITTI数据集进行点云处理…

python中文处理

一、使用中文字符 在python源码中如果使用了中文字符&#xff0c;运行时会有错误&#xff0c;解决的办法是在源码的开头部分加入字符编码的声明&#xff0c;下面是一个例子&#xff1a;#!/usr/bin/env python# -*- coding: cp936 -*-Python Tutorial中指出&#xff0c;python的…

信号量使用例子_用信号量锁定:一个例子

信号量使用例子并发是带来有趣挑战的一个方面。 如果处理不当&#xff0c;会带来种族问题&#xff0c;这会使人们感到困惑&#xff0c;因为这些问题有时会突然出现&#xff0c;并且有时会正常工作。 当处理访问公共资源的并发线程时&#xff0c;Java语言提供了许多处理竞争条件…

.net Reactor之exe、dll文件混淆

.net Reactor之exe、dll文件混淆 .net Reactor的主要功能&#xff1a; 1.是对dll文件、exe文件进行反编译混淆 2.对dll进行内部加锁&#xff0c;限制其使用的固定机器、固定时间、部署次数 2.创建证书文件&#xff0c;用证书管理其限制的机器、时间、部署次数 页面&#xff1a;…

简述SAS逻辑库的概念及建立方法。什么是临时库和永久库?

libname student e:\mysas;SAS中利用libname命令建立逻辑库&#xff0c;虽然之后建立的与其关联的永久数据集还保存在该逻辑库所指的目录中&#xff0c;但重启SAS后该库却没有显示于库目录中。 例如e:\mysas目录已存在&#xff0c;程序data student.aaa;……重启SAS后虽然数据集…

35 岁 学python 必要_程序员:Python学不学?完全没必要纠结

随着云计算、大数据、人工智能的大量应用&#xff0c;Python这毛头小子&#xff0c;成了当红炸子鸡&#xff0c;香飘四溢&#xff0c;撒播到互联网的每个角落里。1几家欢喜几家愁&#xff0c;欢喜的人&#xff0c;早就用上了&#xff0c;国外的Twitter、Google、Yahoo&#xff…

了解连接池

1.简介 连接池是一种通过在池中打开和管理N个数据库连接来提高应用程序性能的技术。 该应用程序只是请求连接&#xff0c;使用它&#xff0c;然后将其放回池中。 当应用程序需要连接时&#xff0c;就绪连接将保持可用状态&#xff0c;以供池中使用。 池管理连接生命周期&#x…

linux上很方便的上传下载文件工具rz和sz

linux上很方便的上传下载文件工具rz和sz(本文适合linux入门的朋友) ######################################################### #《老男孩linux就业培训中心-初级班第七期第一节内容总结。 #linux上很方便的上传下载文件工具rz和sz #date:2011-06-15 #作者&#xff1a;老男孩…

SAS学习︱逻辑库、数据集创建与查看、数据库链接(SAS与R的code对照)

一、逻辑库、数据集、数据字典 数据字典>逻辑库>数据集 逻辑库工作空间&#xff0c;存储四类内容&#xff0c;test是数据集文件&#xff0c;views是视图&#xff08;相当于R里面的views点击查看&#xff09;&#xff0c;formats代表文件&#xff0c;sasmacr代表目录内容…

sqlserver 如何把一列分为一行显示_SqlServer数据库如何快速修改表的一列值

工作中我们会遇到一个表的一列值需要进行整体更换为另一个表的某个字段的值&#xff0c;那么我们该如何处理呢&#xff1f;数据源Room表新的Room表现将Room表的RoomTypeID列替换成Room_new表的RoomTypeID方法一&#xff1a;直接修改update Room set RoomTypeID (select RoomTy…

Linux 命令行通配符及转义符的实现

我们想对一类文件批量操作&#xff0c;例如批量查看硬盘文件属性&#xff0c;那么正常命令会是&#xff1a; [rootlinuxprobe ~]# ls /dev/sda [rootlinuxprobe ~]# ls /dev/sda1 [rootlinuxprobe ~]# ls /dev/sda2 [rootlinuxprobe ~]# ls /dev/sda3 但有些时候确实不知道分区…

windows python 访问mtp存储空间_用Windows电脑训练深度学习模型?超详细配置教程来了...

虽然大多数深度学习模型都是在 Linux 系统上训练的&#xff0c;但 Windows 也是一个非常重要的系统&#xff0c;也可能是很多机器学习初学者更为熟悉的系统。要在 Windows 上开发模型&#xff0c;首先当然是配置开发环境。Kaggle Master 及机器学习实践者 Abhinand 立足于自己的…

Matlab自带排序函数sort用法

Matlab自带排序函数sort用法 [Y,I] sort(X,DIM,MODE) sort函数默认Mode为ascend为升序&#xff0c;sort(X,descend)为降序排列。 sort(X)若X是矩阵&#xff0c;默认对X的各列进行升序排列 sort(X,dim) dim1时等效sort(X) dim2时表示对X中的各行元素升序排列 Matlab中给一维向量…

PostgreSQL学习手册(数据表)

一、表的定义&#xff1a; 对于任何一种关系型数据库而言&#xff0c;表都是数据存储的最核心、最基础的对象单元。现在就让我们从这里起步吧。 1. 创建表&#xff1a; CREATE TABLE products ( product_no integer, name text, price nu…

织梦联动类别-地区调用不显示第三级城市的解决方法

织梦联动类别-地区调用不显示第三级城市的原因 1、附加表dede_addoninfos 或者 你的其他表中的字段nativeplace数据类型为int型&#xff0c;无法保存第三级城市对应的的evalue值(比如&#xff1a;东山区 对应的 10001.001) 2、枚举表dede_sys_enum中的第三级城市对应evalue值…

js 随机1-10随机数_寻找随机的错误-一个真实的故事

js 随机1-10随机数几周前&#xff0c;我完成了RapidFTR开源项目的错误查找 &#xff0c;这花了我三个晚上。 我认为可能值得分享狩猎的故事。 本文将介绍我的工作。 我将概述我的旅程&#xff0c;以便真正找到正在发生的事情的根本原因。 我在本文中的目标是突出显示可以使用的…

用python写九九乘法口诀表左上角_python打出九九乘法口诀表

用IDLE打出乘法口诀表&#xff0c;想要就是如下图的结果&#xff1a;实现算法很简单&#xff0c;但是IDLE(python3.7)默认的换行输出方式不太容易实现&#xff0c;得需费一番脑筋。代码如下&#xff1a;*row0 #设置行数&#xff0c;值为1时候…

设计模式(一)Chain Of Responsibility责任链模式

设计模式篇章&#xff0c;源于网课的学习&#xff0c;以及个人的整理 在我们接收用户提交的字符时&#xff0c;常常会使用到过滤&#xff0c;在学习责任链模式前&#xff0c;我们是这样做的 1.定义一个类 public class MsgProcesser {String msg;public MsgProcesser(String ms…

如果你是IT技术人员,请思考这15个问题

行内的人自嘲是程序猿、屌丝和码农&#xff0c;行外的人也经常拿IT人调侃&#xff0c;那么究竟是IT人没有价值&#xff0c;还是没有仔细思考过自身的价值&#xff1f; 1.搞IT的是屌丝、码农、程序猿&#xff1f; 人们提到IT人的时候&#xff0c;总会想到他们呆板、不解风情&…