<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>样式</title>
<style type="text/css">
.c{
color: red;
}
.box1 {
width: 300px;
height: 300px;
background-color: wheat;
position: relative;
}
.box2 {
width: 100px;
height: 100px;
background-color: coral;
position: absolute;
top: 50px;
left: 100px;
</style>
</head>
<body>
<p>卫庄</p>
<img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523185458556&di=bce75b3dff205ad854fe1b7f48eb65b3&imgtype=jpg&src=http%3A%2F%2Fimg4.imgtn.bdimg.com%2Fit%2Fu%3D4106874994%2C1293263125%26fm%3D214%26gp%3D0.jpg">
<div class="box1">
<div class="box2"></div>
</div>
</body>
</html>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
<script type="text/javascript">
var a = $('img').attr ('width',200)
var b = $('img').css('height',200)
var res = $('img').offset()
$('p').addClass('c')
var res = $('.box2').position().left
</script>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号