position之absolute中left、bottom、top、right与width、height的关系
来源:互联网 发布:自学日语软件下载 编辑:程序博客网 时间:2024/05/21 09:01
1、在网页设计中我们经常遇到宽度自适应,但有时候可能一种高度自适应的问题。这个时候我们的position之absolute就可以帮你了。
2、position之absolute是脱离文档流。当width、height设置某值后,该元素的值就是该值。那width、height没有设置的时候呢?
3、该元素的witdh、height会根据父元素(需设置position:relative,没有则按浏览器作为父元素)的width、height和该元素left、bottom、top、right而改变。
公式:
该元素的witdh = 父元素的width-top-bottom;
该元素的height= 父元素的height-left-right;
该元素位置(该元素left,该元素top);
废话不多说,上图!
html:
1
2
3
4
5
6
<
body
>
<
div
class="container">
<
div
class="B">
</
div
>
</
div
>
</
body
>
css:
1
2
.container {
width
:
600px
;
height
:
600px
;
background
:
#999999
;
position
:
relative
;}
.B {
background
:
#D9C666
;
position
:
absolute
;
top
:
5
1
0px
;
left
:
100px
;
bottom
:
100px
;
right
:
100px
; }
效果:
4、假如有一高度自适应的div,父元素高度300px,里面有两个div,一个高度100px,希望另一个填满剩下的高度
html:
1
2
3
4
5
6
<
div
class="container">
<
div
class="A">
</
div
>
<
div
class="B">
</
div
>
</
div
>
css:
1
2
3
.container {
width
:
600px
;
height
:
300px
;
background
:
#999999
;
position
:
relative
;}
.A {
height
:
100px
;
background
:
#BBE8F2
; }
.B {
width
:
100%
;
background
:
#D9C666
;
position
:
absolute
;
top
:
100px
;
left
:
0
;
bottom
:
0
; }
效果:
就这么简单的完成!
0 0
- position之absolute中left、bottom、top、right与width、height的关系
- css中absolute定位的top bottom left right
- position top bottom left right height z-index
- css定位position,absolute relative两种情况下,top,left,right,bottom的区别
- 当只定义position:absolute时,top,bottom,left,right都不指定,left,top默认值?
- absolute同时设置left,right,top,bottom
- 定位参数:position、left、right、top、bottom
- javascript中各种width,height,left,top的总结
- css之top,right,bottom,left
- absolute,relative,left,right,bottom,top,float,z-index属性的讨论
- html中 left,right,top,bottom图示
- css中定位position、偏移top,bottom,left,right和高宽度设置问题
- margin: left right /top bottom的怪异
- View的位置--top, left, bottom, right
- 元素position设置为fixed而未指定top、bottom、left、right时的定位
- CSS中边偏移属性top,right,bottom,left
- MFC中crect 中的left top right bottom释义
- 关于控件的Left 、Top、Width和Height属性
- 基于色彩恒常( color constancy)特性的Frankle-McCann Retinex图像增强。
- LibGDX 跨平台游戏开发基础教程(总目录)
- 基于灰度世界、完美反射、动态阈值等图像自动白平衡算法的原理、实现及效果
- Wellner 自适应阈值二值化算法
- 任意半径中值滤波(扩展至百分比滤波器)O(1)时间复杂度算法的原理、实现及效果。
- position之absolute中left、bottom、top、right与width、height的关系
- Unsharp Mask(USM)锐化算法的的原理及其实现。
- pdf书籍下载
- Spark-Streaming获取kafka数据的两种方式-Receiver与Direct的方式
- 关于.net中获取图像缩略图的函数GetThumbnailImage的一些认识。
- PS色调均化滤镜的快捷实现(C#源代码)。
- JavaScript 排序算法汇总
- Android studio 修改 app的 build.gradle实现同一APP不同版本同时存在(同一APP安装N次)
- 图像柔光效果(SoftGlow)的原理及其实现。