p {
width:200px;
height:200px;
border:1px solid green;
margin-left:500px;
margin-top:100px;
}
hr{ border:1px solid red; }
这是p
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
需要给p加一个属性position:absolute或者是relative
元素位置计算错误
使用相对于document的位置
offset方法或相对于offsetParent的位置
position方法使left属性生效,需要给元素加加入 position:absolute或者是position:relative
添加position属性
同时
JQ有$().left();这个方法嘛。。?样式不是你这么玩的吧?要用函数的话用.offset吧。
需要增加position:absolute的属性