CSS中相对定位
来源:互联网 发布:软件源码提取 编辑:程序博客网 时间:2024/05/03 19:16
相对定位是按照元素自身所在的位置,使用边偏移属性重新定义元素的显示位置,使用相对定位的元素依然是文档中的元素,元素的显示位置和
元素所在文档中其他元素相互关联。
在确定相对定位元素位置的时候,首先要确定元素的原始位置,即元素在文档中的位置,然后根据偏移属性中定义的偏移值,确定元素的最终位置。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <style> .div1 { background: #333333; width: 200px; height: 100px;}.relative { position: relative; top: 50px; left: 100px; width: 400px; height: 100px; background: #666666;} </style> </head> <body> <div class="div1"></div> <div class="relative">这是相对定位到元素</div> </body></html>
从上图可以看出,使用相对定位的元素按照自身所在的位置进行偏移。
在使用相对定位到时候,相对定位元素保留原来所占有的空间,同时自身按照边偏移属性中定义的属性值进行偏移(有可能覆盖其他元素),
与相对定位元素相邻的元素会将相对定位元素进行排列。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <style> .div1 { background: #333333; width: 200px; height: 100px;}.relative { position: relative; top: 50px; left: 100px; width: 400px; height: 100px; background: #666666;} .div2 { background: #999999; width: 200px; height: 100px;} </style> </head> <body> <div class="div1"></div> <div class="relative">这是相对定位到元素</div> <div class="div2"></div> </body></html>
从上图看出,与相对定位元素相邻的元素的显示方式,会保留相对元素原来占有的空间,使用相对定义的元素,由于其显示级别高于
普通元素,所以相对定位元素覆盖了普通页面元素。
- CSS中相对定位
- css中相对定位和绝对定位
- css中绝对定位和相对定位
- css中绝对定位和相对定位
- css中相对定位和绝对定位
- css定位中绝对定位和相对定位的区别
- 对css中绝对定位与相对定位的理解
- CSS中关于绝对定位和相对定位
- CSS中相对定位和绝对定位的应用
- CSS样式中 绝对定位和相对定位
- div+css 中相对定位于绝对定位的详解
- CSS中关于定位的问题, 相对,绝对定位
- css中绝对定位与相对定位的区别
- css中绝对定位absolute和相对定位relative
- CSS中相对定位和绝对定位理解
- css中绝对定位和相对定位的理解
- CSS中position绝对定位和相对定位
- CSS中position绝对定位和相对定位
- 对《COM技术内幕》第10章的不满意
- spring mvc 报错found for dependency: expected at least 1 bean which qualifies as autowire candidate fo
- Under The Moon——5、Forest fires
- Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict,
- HTML5的明天, 局部有小雨
- CSS中相对定位
- 调用非托管dll常出现的bug及解决办法
- Resource is out of sync with the file system解决办法
- linux同步机制
- pcap文件解析--pcap文件头与包文件头(一)
- 软件的完整文档
- TSPITR(基于时间点的表空间恢复)
- 考研英语做题经验之谈(一)
- 应该知道的Linux技巧