css div position to parent
2015-06-08 16:19
603 查看
To position an element "fixed" relative to a parent element, you want
For example:
This will position
To position an element "fixed" relative to the window, you want
For example:
This will position
position:absoluteon the child element, and any position mode other than the default or static on your parent element.
For example:
#parentDiv { position:relative; } #childDiv { position:absolute; left:50px; top:20px; }
This will position
childDivelement 50 pixels left and 20 pixels down relative to parentDiv's position.
To position an element "fixed" relative to the window, you want
position:fixed, and can use
top:,
left:,
right:, and
bottom:to position as you see fit.
For example:
#yourDiv { position:fixed; bottom:40px; right:40px; }
This will position
yourDivfixed relative to the web browser window, 40 pixels from the bottom edge and 40 pixels from the right edge.
相关文章推荐
- 通过position属性实现文本在页面中的任意位置
- 使用CSS代码的空格实现中文对齐的方法
- 深入理解CSS的height:100%和height:inherit之间的使用区别
- CSS3 @font-face
- css3 shadow实现的各种漂亮阴影效果
- css3大小单位px、pt、em和rem的区别
- CSS实现垂直居中的5种方法
- 让IE6支持css3,让 IE7、IE8 都支持CSS3
- css定位
- CSS3 icon font
- css sprite、background-size、Retina屏幕详解
- html/css编写规范
- css3属性书写的时候带的一些前缀的意思
- CSS 选择符
- 源码推荐(6.8):带标题、可改变样式的自定义ActionSheet,TYWaterWaveView 水波浪圆形进度
- "portrait"(竖屏) "landscape"(横屏) css设置
- 【code】flex_进度条样式
- CSS Masking(翻译)
- css小知识
- Css浮动的含义和div卡住状况的分析