属性定义及使用说明
对于绝对定位元素,bottom属性设置单位高于/低于包含它的元素的底边。
对于相对定位元素,bottom属性设置单位高于/低于其正常位置的元素的底边。
注意:如果”position:static”,底部的属性没有任何效果。
说明: 对于 static 元素,为 auto;对于长度值,则为相应的绝对长度;对于百分比数值,为指定值;否则为 auto。 对于相对定义元素,如果 bottom 和 top 都是 auto,其计算值则都是 0;如果其中之一为 auto,则取另一个值的相反数;如果二者都不是 auto,bottom 将取 top 值的相反数。
| 默认值: | auto |
|---|---|
| 继承性: | no |
| 版本: | CSS2 |
| JavaScript 语法: | object.style.bottom=”50px” |
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
| 属性 | 谷歌 | IE | 火狐 | 苹果 | opera |
|---|---|---|---|---|---|
| bottom | 1.0 | 5.0 | 1.0 | 1.0 | 6.0 |
属性值
| 值 | 描述 |
|---|---|
| auto | 默认值。通过浏览器计算底部的位置。 |
| % | 设置以包含元素的百分比计的底边位置。可使用负值。 |
| length | 使用 px、cm 等单位设置元素的底边位置。可使用负值。 |
| inherit | 规定应该从父元素继承 bottom 属性的值。 |
实例
设置图像的底部边缘,在元素的底边上面5px:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Web176教程(web176.com)</title>
<style>
img.ex1
{
position:absolute;
bottom:0px;
}
img.ex2
{
position:relative;
bottom:-100px;
}
</style>
</head>
<body>
<img src="/wp-content/uploads/2022/02/CSS.jpg" width="100" />
<h1>This is a heading</h1>
<img src="/wp-content/uploads/2022/02/CSS.jpg" width="100" />
</body>
</html>作者:terry,如若转载,请注明出处:https://www.web176.com/cssprop/5440.html
支付宝
微信