0
点赞
收藏
分享

微信扫一扫

jquery位置1


jquery位置1_jquery

 

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_前端_03

 

举报

相关推荐

0 条评论