主要是针对格式布局的一些内容:

1:position:fix

锁定位置(相对于浏览器的位置),例如网上弹出的一些广告

<style type="text/css">
#a
{
border:2px solid blue;
height:100px;
width:100px;
background-color:#0F6;
right:60px;
bottom:70px;
position:fixed;} </head>
<body> <div id="a">今天是个好日子,后面打上n个回车可以明显看出</div>

2.position :absolute

1.外层没有position:absolute(或relative);那么div相对于浏览器定位,

2.外层有position:absolute(或relative);那么div相对于外层边框定位,

.b
{
border:2px solid blue;
height:100px;
width:100px;
background-color:#0F6;
right:0px;
bottom:0px;
position:absolute;}
.c
{
border:2px solid red;
width:400px;
height:200px;}
.d
{
border:2px solid red;
width:400px;
height:200px;
position:absolute;} </style>
</head>
<body>
<div class="b">.b的器相对于整个页面的bc和下面效果相仿</div>
<div class="c">.c的相对于这么多空格结束后的</div>
<div class="c">ccc<div class="b">bbb</div></div>
<div class="d">dddd又来一个</div>
<div class="d">d<div class="b">b</div></div>

3.position: relative

相对位置

相对于把此div包含住的div的某个位置进行固定。如果外层没有包含他的,那就相对于浏览器进行相对位置的固定。

#aaa
{
border:2px solid yellow;
background-color:#9F3;
height:100px;
width:100px;
left:30px;
top:30px;
position:fixed;}
#bbb
{
border:2px solid yellow;
background-color:#9F3;
height:100px;
width:100px;
left:30px;
top:30px;
position:relative;} </style>
</head>
<body>
<div id="aaa">aaaaaa</div>
<div id="bbb">bbbbbb</div>
<div id="aaa">aiyou<div id="bbb">ganha是b相对a</div></div>

两种情况都试了看一下不同

(二)分层(Z-index)

在z轴方向分层,可以理解为分成一摞纸,层数越高越靠上。

  在上面relative的示例中,我们看到了aa遮住了a,这是因为后写代码的显示级别越靠前,那么在不改变代码顺序的情况下如何让a盖住aa?

只需要把添写上z-index:2就可以了

(三)float:left、right

Left、right时不用给他规定位置(left、top),直接相对于浏览器。若外部被包裹,相对于外部div的除去一行的位置的左上或右上显示。

#cc
{
border:#0C0 solid 2px;
height:300px;
width:100px;
float:right;}
#dd
{
border:#0C0 solid 2px;
height:300px;
width:100px;
float:right;}
#ee
{
border:#0C0 solid 2px;
height:300px;
width:100px;
float:left;}
#ff
{
border:#0C0 solid 2px;
height:300px;
width:100px;
float:left;} </style>
</head>
<body>
<div id="cc">没吃饭 相对游览器</div>
<div id="dd">吃饭了吗</div>
<div id="ee">你好</div>
<div id="ff">我很好</div>
</body>
</html>

  overflow:hidden;    //超出部分隐藏;scroll,显示出滚动条;

  <div style="clear:both"></div>   //截断流

3月23 格式布局及relative的更多相关文章

  1. CSS样式表与格式布局

    样式表 CSS(Cascading Style Sheets  层叠样式表),作用是美化HTML网页. 内联样式表: 例:<p style="font-size:10px;" ...

  2. Linux自用指令——2019年10月23日

    1.ls ls命令是列出目录内容(List Directory Contents)的意思.运行它就是列出文件夹里的内容,可能是文件也可能是文件夹. ls -a 列出目录所有文件,包含以.开始的隐藏文件 ...

  3. 2016年12月23日 星期五 --出埃及记 Exodus 21:18

    2016年12月23日 星期五 --出埃及记 Exodus 21:18 "If men quarrel and one hits the other with a stone or with ...

  4. [分享] 从定制Win7母盘到封装详细教程 By BILL ( 10月23日补充说明 )

    [分享] 从定制Win7母盘到封装详细教程 By BILL ( 10月23日补充说明 ) billcheung 发表于 2011-10-23 00:07:49 https://www.itsk.com ...

  5. 11月23日《奥威Power-BI报表集成到其他系统》腾讯课堂开课啦

    听说明天全国各地区都要冷到爆了,要是天气冷到可以放假就好了.想象一下大冷天的一定要在被窝里度过才对嘛,索性明天晚上来个相约吧,相约在被窝里看奥威Power-BI公开课如何?        上周奥威公开 ...

  6. 2016年11月23日 星期三 --出埃及记 Exodus 20:14

    2016年11月23日 星期三 --出埃及记 Exodus 20:14 "You shall not commit adultery.不可奸淫.

  7. 2016年10月23日 星期日 --出埃及记 Exodus 19:7

    2016年10月23日 星期日 --出埃及记 Exodus 19:7 So Moses went back and summoned the elders of the people and set ...

  8. 2016年6月23日 星期四 --出埃及记 Exodus 14:20

    2016年6月23日 星期四 --出埃及记 Exodus 14:20 coming between the armies of Egypt and Israel. Throughout the nig ...

  9. SWT中的布局之-----FormLayout(表格式布局)

    表格式(FormLayout类) 表格式布局管理器,通过创建组件各个边的距离来布局组件,和GridLayout一样强大. 用GridLayout与FormLayout都可以实现相同的界面效果,但有时使 ...

随机推荐

  1. js希尔排序

    function shellSort (arr) { var len = arr.length; var increment = Math.floor(len/2); while(increment! ...

  2. 什么情况下用断言?assert

    可以再预计正常情况下不会到达的任何位置上放置断言,断言可以用于验证传递给私有方法的参数.不俺的参数过,断言不应该用于验证传递给公有方法的参数,因为不管是否启用了断言,公有方法都必须检查其参数.不过,既 ...

  3. 最大匹配字符串LCS,The Longest Common Substring

    public enum BackTracking { UP, LEFT, NEITHER, UP_AND_LEFT } public abstract class LCSBaseMatch { /// ...

  4. Jenkins-pipeline

    https://my.oschina.net/ghm7753/blog/371954?p=1

  5. CSS-形变 动画 表格

    一.形变 /*1.形变参考点: 三轴交界点*/ transform-origin: x轴坐标 y轴坐标; ​ /*2.旋转 rotate deg*/ transform: rotate(720deg) ...

  6. Lintcode521-Remove Duplicate Numbers in Array-Easy

    Description Given an array of integers, remove the duplicate numbers in it. You should: Do it in pla ...

  7. SAP固定资产业务场景及方案

    SAP固定资产业务场景及方案 http://mp.weixin.qq.com/s/hYlaNHJMQBTZpyFAmP2h3A 对于FICO应用资深专家或顾问,须业务场景及需求成竹在胸:对于非财务顾问 ...

  8. 微信小游戏开发之JS面向对象

    //游戏开发之面向对象 //在js的开发模式中有两种模式:函数式+面向对象 //1.es5 // 拓展一:函数的申明和表达式之间的区别 // 函数的申明: // function funA(){ // ...

  9. CIKM 18 | 蚂蚁金服论文:基于异构图神经网络的恶意账户识别方法

    小蚂蚁说: ACM CIKM 2018 全称是 The 27th ACM International Conference on Information and Knowledge Managemen ...

  10. P1031 均分纸牌

    题目描述 有N堆纸牌,编号分别为 1,2,…,N1,2,…,N.每堆上有若干张,但纸牌总数必为N的倍数.可以在任一堆上取若干张纸牌,然后移动. 移牌规则为:在编号为1堆上取的纸牌,只能移到编号为2的堆 ...