一、positionfixed

  锁定位置(相对于浏览器的位置),例如有些网站的右下角的弹出窗口。

     显示效果  无论滚动条怎么移动  都固定在显示页面的一个位置不动

二、positionabsolute

  1.外层没有position:absolute(或relative);那么div相对于浏览器定位,如下图中b(距离浏览器右边框为50像素,距离下边框为20像素)。

  2.外层有position:absolute(或relative);那么div相对于外层边框定位,如下图中bb(距离d的右边框50像素,距离d的下边框为20像素)。

示例:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.b{
border:5px solid blue;
background-color:#009;
width:100px;
height:100px;
margin:30px;
right:50px;
bottom:20px;
position:absolute;
}
.c{
width:400px;
height:200px;
border:2px solid red; }
.d{
border:2px solid red;
width:400px;
height:200px;
position:absolute;
}
</style>
</head> <body>
<div class="c"><div class="b">b</div></div>
<div class="d"><div class="b">bb</div></div>
</body>
</html>
不同比例的显示效果图,见下面。

三、positionrelative

  相对位置。

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

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>absolute</title>
<style type="text/css">
#a{
border:5px solid blue;
background-color:#0F3;
width:100px;
height:100px;
margin:10px;
position:fixed; }
#aa{
border:5px solid blue;
background-color:#0F3;
width:100px;
height:100px;
margin:10px;
left:20px;
top:50px;
position:relative;
} </style>
</head> <body>
<div id="a">a</div>
<div id="aa">aa</div>
</body>
</html>

显示效果

四、分层(z-index

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

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

示例:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.a{
border:5px solid blue;
width:100px;
height:100px;
background-color:#0F3;
margin:10px;
position:fixed;
z-index:2;/*"2"这个参数可做修改,默认情况下,都是第一层*/
}
.aa{
border:5px solid blue;
width:100px;
height:100px;
margin:10px;
background-color:#0F3;
left:20px;
top:50px;
position:relative;
}
</style>
</head> <body> <div class="a">a</div>
<div class="aa">aa</div>
</body>
</html>

五、floatleftright

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

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

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

附:cursor:pointer    鼠标指到上面时的形状

&copy                  版权符号©

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#a{
background-color:#0F0;
border:1px solid blue;
margin:10px;
height:100px;
width:100px;
float:right;
overflow:hidden;/把hidden改为scroll,由隐藏溢出的文字方式,变为有滚动条显示的方式
} </style>
</head> <body>
<div id="a">道可道非常道,名可名非常。无名,天地之始。有名,万物之母。常无欲观其妙,常有欲观其徼。此两者同出而异名。同谓之玄,玄而又玄,众妙之门。</div>
</body>
</html>

overflow:hidden;形式把溢出的隐藏        overflow:scroll;形式  带滚动条

半透明效果:

  <div class="box">透明区域<div>

在样式表中的代码为:

.box

{

opacity:0.5; -moz-opacity:0.5 ; filter:alpha(opacity=50)

}

filter填充   alpha透明   opacity模糊

2016/2/19 position: fixed absolute relative z-index float 半透明效果的更多相关文章

  1. css 定位(fixed > absolute > relative)与层级zIndex 的权限认知

    原则1: fixed > absolute > relative原则2: zIndex 越高越牛逼,不管你是谁无视身份.原则3: 青出于蓝而胜于蓝,儿子永远比父亲强原则4: 平台很重要. ...

  2. CSS position绝对定位absolute relative

    常常使用position用于层的绝对定位,比如我们让一个层位于一个层内具体什么位置,为即可使用position:absolute和position:relative实现. 一.position语法与结 ...

  3. CSS position属性absolute relative等五个值的解释

    DIV CSS position绝对定位absolute relative教程篇 常常使用position用于层的绝对定位,比如我们让一个层位于一个层内具体什么位置,为即可使用position:abs ...

  4. css总结1:position定位:absolute/relative/fixed

    1 [Positioning(定位)] Positioning作用:指定了元素的定位类型.position包括四个值:static,relative,fixed,absolute. css定位解析:元 ...

  5. 一起学HTML基础-格式与布局fixed/absolute/relative/z-index/float

    很多网页都存在一个悬浮的操作条或者广告区,无论如何上下滚动网页,操作条或广告区都不会动,这个就是div制作,位置锁定在屏幕指定位置,现在我们就学习下网页的格式与布局. position 位置,来给di ...

  6. HTML-★★★格式与布局fixed/absolute/relative/z-index/float★★★

    很多网页都存在一个悬浮的操作条或者广告区,无论如何上下滚动网页,操作条或广告区都不会动,这个就是div制作,位置锁定在屏幕指定位置,现在我们就学习下网页的格式与布局. position 位置,来给di ...

  7. day2-设置position:fixed/absolute无法使用margin:auto调整居中

    问题描述:父元素给定宽度,子元素给定宽度,设置子元素position为absolute/fixed后,无法使用margin:auto使子元素在父元素中水平居中 html代码如下: <div cl ...

  8. css中position属性(absolute|relative|static|fixed)概述及应用

    position属性的相关定义: static:无特殊定位,对象遵循正常文档流; relative:对象遵循正常文档流; absolute:对象脱离正常文档流 fixed:对象脱离正常文档流 我们先来 ...

  9. 【转】CSS中position属性( absolute | relative | static | fixed )详解

    我们先来看看CSS3 Api中对position属性的相关定义: static:无特殊定位,对象遵循正常文档流.top,right,bottom,left等属性不会被应用. relative:对象遵循 ...

随机推荐

  1. php基础查找算法

    1.顺序查找 function line_search($array,$tar) { if(!is_array($array) || count($array) < 1) return fals ...

  2. Android Bitmap详细介绍(3)

    package com.testbitmapscale; import java.io.File; import java.io.FileInputStream; import java.io.Fil ...

  3. ffmpeg裁剪

    http://it6655.com/2012/09/ffmpeg-9-2-html 1 configure参数 1 通用选项 在linux下进入终端,找到ffmpeg解压位置,输入如下命令: root ...

  4. Tensor数据类型

    目录 Tensor数据类型 属性 数据类型判断 数据类型转换  tensor转numpy Tensor数据类型 list: [1,1.2,'hello'] ,存储图片占用内存非常大 np.array, ...

  5. 我们参与投资36Kr股权众筹项目“易途8”的决策过程

     背景   中文接机.中文送机.中文包车. 当地玩乐   最大的竞争对手:皇包车,15年9月A轮   其它对手:唐人接等,订单量无法和 皇包车.易途8比.    看好理由 1.旅游行业和境外自由行,是 ...

  6. ALLEGRO中新画的热风焊盘不能找到的解决办法

    新画的热风焊盘(PCB Thermal Relif)改了路径,要想在Pad Designer中找到,方法是在allegro中Setup-User Preference Editor-Paths-Lib ...

  7. jQuery_DOM学习之------clone()

    jQuery_DOM学习之------clone() clone()---节点克隆: 方法: 1.clone()只克隆结构,事件将被丢弃 2.clone(true)结构和事件都将被克隆 例子: < ...

  8. 九度oj 题目1072:有多少不同的面值组合?(set集合)

    题目1072:有多少不同的面值组合? 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3627 解决:1852 题目描述: 某人有8角的邮票5张,1元的邮票4张,1元8角的邮票6张,用这些邮 ...

  9. [luoguP1388] 算式(DP)

    传送门 看这个n<=15本以为是个状压DP 还是too young 这个题最神奇的地方是加括号是根据贪心的策略. 发现只有在一连串的加号两边加上括号才是最优的(想一想,为什么?) f[i][j] ...

  10. SQLAlchemy(1):单表操作

    SQLAlchemy 是一个 ORM框架:类对应表,类中的字段对应表中的列,类的对象对应表的一条记录:作用:帮助我们使用类和对象快速实现数据库操作操作数据库的方式: 1. 原生SQL - pymysq ...