问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
padding: 0px;
margin: 0px;
}
body{
text-align: center;
}
img{
margin: 200px;
height: 230px;
width: 130px;
}
</style>
</head>
<body>
<img src="" alt="" myImg="webp.webp.jpg" id="pic">
<script>
var pic = document.getElementById('pic');
var picTop=pic.offsetTop;
var screen = document.body.clientHeight;
console.log(screen);
</script>
</body>
</html>
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果