您当前的位置: 首页 > 

顺其自然~

暂无认证

  • 0浏览

    0关注

    1317博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

DOM position 属性

顺其自然~ 发布时间:2021-03-23 13:15:04 ,浏览量:0

定义和用法

position 属性把元素放置到一个静态的、相对的、绝对的、或固定的位置中。

语法:
Object.style.position=static|relative|absolute|fixed
可能的值 值描述static默认。位置设置为 static 的元素,它始终会处于页面流给予的位置(static 元素会忽略任何 top、bottom、left 或 right 声明)。relative位置被设置为 relative 的元素,可将其移至相对于其正常位置的地方,因此 "left:20" 会将元素移至元素正常位置左边 20 个像素的位置。absolute位置设置为 absolute 的元素,可定位于相对于包含它的元素的指定坐标。此元素的位置可通过 "left"、"top"、"right" 以及 "bottom" 属性来规定。fixed位置被设置为 fixed 的元素,可定位于相对于浏览器窗口的指定坐标。此元素的位置可通过 "left"、"top"、"right" 以及"bottom" 属性来规定。不论窗口滚动与否,元素都会留在那个位置。工作于 IE7(strict 模式)。 实例

本例把元素位置由相对改为绝对:




input
{
position:relative;
}


function setPositionAbsolute()
{
document.getElementById("b1").style.position="absolute";

document.getElementById("b1").style.top="10px";
}




This is an example paragraph

This is an example paragraph

 

关注
打赏
1662339380
查看更多评论
立即登录/注册

微信扫码登录

0.0399s