CSS样式定位
来源:互联网 发布:黄金时代超人 知乎 编辑:程序博客网 时间:2024/06/17 21:40
<html> <head> <title>CSS样式定位</title> <!--定位:定义元素的位置--> <!--定位有三种方式:普通流(默认),绝对定位,相对定位--> <style type="text/css"> /*绝对定位:以网页坐标系为基准进行定位*/ #box-abs{ position:absolute; left:100px; top:100px; border:1px dashed red; } </style> <style type="text/css"> /*相对定位:相对元素原始的位置定位*/ .pos{ position:relative; left:200px; top:50px; } .pos-left{ position:relative; left:500px; } .pos-top{ position:relative; top:-100px; } </style> <style type="text/css"> /*z-index属性:值越小,越靠近底部,可以是负数,默认值为0*/ /*要想使用z-index属性必须使用postion:absolute/relative/fixed三个属性之一。*/ .box1{ position:absolute; left:500px; top:500px; z-index:1; width:300px; height:150px; border:1px solid black; margin-top:20px; background-color:red; } .box2{ position:absolute; left:550px; top:550px; z-index:2; width:300px; height:150px; border:1px solid black; margin-top:20px; background-color:yellow; } .box3{ position:absolute; left:600px; top:600px; z-index:3; width:300px; height:150px; border:1px solid black; margin-top:20px; background-color:blue; } </style> </head> <body> <p id="box-abs">获取,理解,拓展,应用,纠错</p> <br><br><br><br> <h2>1标题</h2> <h2 class="pos">2标题左下移动</h2> <h2 class="pos-left">3标题向左移动</h2> <h2 class="pos-top">4向上移动</h2> <br><br><br><br> <h1 class="box1">标题一</h1> <h1 class="box2">标题二</h1> <h1 class="box3">标题三</h1> </body></html>
1 0
- Css样式详解--定位
- CSS样式的定位
- CSS样式定位
- CSS定位样式
- CSS样式之position定位
- 小谈css样式div定位
- css样式中关于定位的问题
- css样式-盒子、定位、背景色、尺寸
- css基础样式(9)-定位、浮动
- CSS样式表一席谈之绝对定位与相对定位
- CSS样式中 绝对定位和相对定位
- css样式定位属性之绝对定位的利用
- 关于css样式绝对定位、相对定位、固定定位的疑难杂症
- 搞清CSS样式中background-position(背景图片定位)
- 【css】day03_文本格式化_表格样式_定位
- 关于css样式 自适应和绝对定位 的一点理解
- div+css 之 定位 position与样式选择器
- 常用的滑动、隐藏、定位等CSS样式
- ListView的不同item加载不同Layout
- 32位和64位系统区别及int字节数
- 剑指Offer—编程题42(翻转单词顺序)
- WP_Image_Editor_Imagick 漏洞临时解决方法
- Palindrome Number
- CSS样式定位
- opensipsctl使用
- IComparer<T>的运用
- 走进爱哥的仓库:DatePicker
- rtpproxy 配置
- android 加载html页面
- makefile:3: *** missing separator.
- Java文件读写
- LiME