首页 > 其他分享 >jquery位置1

jquery位置1

时间:2023-02-10 10:01:12浏览次数:46  
标签:jquery console log top 位置 100px son width


jquery位置1_html

 

jquery位置1_前端_02

 

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./js/jquery.min.js"></script>
<style>
.father {
width: 200px;
height: 200px;
background-color: pink;
margin-left: 100px;
margin-top: 100px;
position: relative;
}

.son {
width: 100px;
height: 100px;
background-color: red;
}
</style>
</head>

<body>
<div class="father">
<div class="son"></div>
</div>
<script>
$(function() {
//width 不受父级别影响
console.log($(".son").offset());
console.log($(".son").offset().top);
//设置
$(".son").offset({
top: 200,
left: 200
})
//只能获取 不能赋值
console.log($(".son").position())
})
</script>
</body>

</html>

运行结果

jquery位置1_jquery_03

 

标签:jquery,console,log,top,位置,100px,son,width
From: https://blog.51cto.com/u_15460007/6048628

相关文章