小白教程
所有教程
关于
Search
108.162.216.107
108.162.216.107
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Pr pos top”的源代码
本页内容
上一节:
Pr_pos_right
下一节:
Pr_class_visibility
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:top}}[[Category:css reference|169]] = CSS top 属性 = 把图像的上边缘设置在其包含元素上边缘之下5像素高的位置: <sample title="" desc="" lang="html" hererun="1"> img { position:absolute; top:5px; } </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> img { position:absolute; top:0px; } </style> </head> <body> <img src="logocss.gif" width="95" height="84"> <h1>This is a heading</h1> </body> </html> </run> == 属性定义及使用说明 == top 属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 对于相对定义元素,如果 top 和 bottom 都是 auto,其计算值则都是 0;如果其中之一为 auto,则取另一个值的相反数;如果二者都不是 auto,bottom 将取 top 值的相反数。 '''注意:''' 如果 "position" 属性的值为 "static",那么设置 "top" 属性不会产生任何效果。 {| class="table table-striped table-hover" | 默认值: | auto |- | 继承: | no |- | 版本: | CSS2 |- | JavaScript 语法: | object.style.top="50px" |} == 浏览器支持 == 表格中的数字表示支持该属性的第一个浏览器版本号。 {| class="table table-striped table-hover" ! 属性 ! Chrome ! Internet Explorer / Edge ! Firefox ! Safari ! Opera |- | top | 1.0 | 5.0 | 1.0 | 1.0 | 6.0 |} == 属性值 == {| class="table table-striped table-hover" ! 值 ! 描述 |- | auto | 默认值。通过浏览器计算上边缘的位置。 |- | % | 设置以包含元素的百分比计的上边位置。可使用负值。 |- | length | 使用 px、cm 等单位设置元素的上边位置。可使用负值。 |- | inherit | 规定应该从父元素继承 top 属性的值。 |} == 相关文章 == CSS 教程: [[css positioning|CSS Positioning]]
返回至“
Pr pos top
”。
上一节:
Pr_pos_right
下一节:
Pr_class_visibility