css-position属性实例2
position
1) fixed 固定在页面某个位置
2) absolute 也可以固定在某个位置,一般结合relative使用
注:
1)fixed和absoulue区别,假如一个div固定在右下角。滚动滑轮时,fixed是一直固定在右下角,而absolute是跟着走滑轮走。
2)
<div style="position:relative;">
<div style="position:absolute;top:0;left:0;> <!--这个时候就不是以整个页面固定,而是以父类标签的某个位置固定-->
</div>
absolute示例:固定位置
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body> <div style="height: 40px;width: 40px;color: white;position: absolute;right: 0;bottom:0 ">1111</div>
<div style="height: 5000px;background-color: red"></div> </body>
</html>
relative+absolute示例:以父类标签的某个位置固定
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div style="height: 200px;width: 500px;border: 1px solid red;position: relative;margin: 0 auto">
<div style="height: 40px;width: 40px;position: absolute;top:0;right: 0"></div>
</div>
<div style="height: 200px;width: 500px;border: 1px solid red;position: relative;margin: 0 auto">
<div style="height: 40px;width: 40px;position: absolute;bottom:0;left: 0"></div>
</div>
<div style="height: 200px;width: 500px;border: 1px solid red;position: relative;margin: 0 auto">
<div style="height: 40px;width: 40px;position: absolute;top:0;left: 0"></div>
</div>
</body>
</html>
示例:多层使用
1)使用position固定
2)使用opacity设置透明度
3)z-index设置权重,越大表示越显示在上面
4)position: fixed;top:50%;left: 50% 是以左上角来固定,通过margin-left: -250px;margin-top: -250px;来调整使第三个div居中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div style="position: fixed;top:50%;left: 50%;z-index: 10;height: 400px;width: 400px;margin-left: -250px;margin-top: -250px;"></div>
<div style="position: fixed;top:0;left: 0;right: 0;bottom:0;opacity: 0.5;z-index: 9"></div>
<div style="height: 5000px;z-index: 8"></div>
</body>
</html>
css-position属性实例2的更多相关文章
- 【转载】CSS position属性和实例应用
目前几乎所有主流的浏览器都支持position属性("inherit"除外,"inherit"不支持所有包括IE8和之前版本IE浏览器,IE9.IE10还没测试 ...
- CSS position属性absolute relative等五个值的解释
DIV CSS position绝对定位absolute relative教程篇 常常使用position用于层的绝对定位,比如我们让一个层位于一个层内具体什么位置,为即可使用position:abs ...
- 详解CSS position属性
原文地址:http://luopq.com/2015/11/15/css-position/ position是CSS中非常重要的一个属性,通过position属性,我们可以让元素相对于其正常位置,父 ...
- css position 属性 (absolute 和fixed 区别)
在css3中,position的属性值有:inherit, static, relative ,absolute, fixed. inherit 是继承父元素的position属性值,IE不支持. s ...
- CSS position 属性
position: relative | absolute | static | fixed 参考网站:http://blog.csdn.net/dyllove98/article/details/8 ...
- CSS position 属性_css中常用position定位属性介绍
css可以通过为元素设置一个position属性值,从而达到将不同的元素显示在不同的位置, position定位是指定位置的定位,以下为常用的几种: 1.static(静态定位): 这个是元素的默认定 ...
- css position属性
absolute, 屏幕为参照, 但固定在页面上,随页面滚动而动. fixed, 父元素没有指定position属性(或position属性为static时)==>屏幕为参照,固定在屏幕的某个位 ...
- CSS position属性 标签: css 2016-09-06 15:58 78人阅读 评论(0) 收藏
踩了position的坑,主要是因为对position属性理解不深. 以下是w3school中对position的解释: 可能的值 值 描述 absolute 生成绝对定位的元素,相对于 static ...
- CSS position属性---absolute与relative
详情请点击此链接 http://www.cnblogs.com/polk6/archive/2013/07/26/3214847.html
- CSS - position属性小结
Relative: 属于文档流,针对自身进行偏移: Absolute: 脱离文档流,针对最近的定位元素进行偏移,如果没有,则针对根元素,即body标签尽心偏移: Fixed: 和absolute基本一 ...
随机推荐
- css 鼠标移上去会变大
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- BCB将RichEdit光标移到最后一行
int linecount=RichEdit1->Lines->Count; RichEdit1-> SelStart=SendMessage(RichEdit1-> Hand ...
- iOS 打开系统设置的常用功能
说明: 跳转到系统设置不同功能界面,只要知道路径都很简单,路径可以自己打开手机设置界面看, 照着模板把对应的名称替换就可以了,但是得知道对应功能的英文名称. 1. prefs:root=Privacy ...
- Eclipse中项目上有小红叉,但就是找不到报错文件(总结,持续更新)
1.jdk问题解决:jdk配置参考:http://blog.csdn.net/superit401/article/details/72847110 2.build path:项目右键——Build ...
- ef 更新数据库
//一:数据库不存在时重新创建数据库 Database.SetInitializer<testContext>(new CreateDatabaseIfNotExists<testC ...
- c# winform 为按钮动态背景图片
参考自:http://www.cnblogs.com/sufei/archive/2012/11/15/2771299.html 第一种,使用Properties.Resources类,这种方法需要你 ...
- 【bzoj1044】木棍分割
Description 有n根木棍, 第i根木棍的长度为Li,n根木棍依次连结了一起, 总共有n-1个连接处. 现在允许你最多砍断m个连接处, 砍完后n根木棍被分成了很多段,要求满足总长度最大的一段长 ...
- 洛谷4859 BZOJ3622 已经没什么好害怕的了(DP,二项式反演)
题目链接: 洛谷 BZOJ 题目大意:有两个长为 $n$ 的序列 $a,b$,问有多少种重排 $b$ 的方式,使得满足 $a_i>b_i$ 的 $i$ 的个数比满足 $a_i<b_i$ 的 ...
- python 用Threading创建多线程
#-*-coding:utf-8-*- '''python标准库提供了两个多线程模块,分别为thread和threading, 其中thread模块是低级模块,threading是高级模块,对thre ...
- 【uoj428】普通的计数题
Portal --> uoj428 Solution 不会胖子的一个log正解qwq只能怂怂滴写分治了qwq 首先就是一个我想不到的转化qwq 我们将第\(i\)次操作加入的数看成一个编 ...