我在我的网站主页上放了一张图片,但我想移动图片的位置而不是操纵图片的像素。我确定它与填充或边距有关,但是我不确定如何将它实现到我的程序中。这是我的代码:
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheetMain.css">
<title> Main Page </title>
</head>
<body>
<!-- This is the image I want to move around! -->
<img src="blake.jpg" alt="Mountain View" style="width:141px;height:114px;">
<div class="link1" onclick="location.href='';" style="cursor: pointer;">
</div>
<div class="link2" onclick="location.href='ImagePage.html';" style="cursor: pointer;">
</div>
<div class="link3" onclick="location.href='gamequiz.html';" style="cursor: pointer;">
</div>
<div class="link4" onclick="location.href='orderform.html';" style="cursor: pointer;">
</div>
<div class="link5" onclick="location.href='comments.html';" style="cursor: pointer;">
</div>
<div class="link6" onclick="location.href='';" style="cursor: pointer;"><br><br><br>
Author: Michael Cattermole
</div>
</body>
</html>
最佳答案
您只能设置组件的位置,如果位置是相对的、固定的或绝对的。如果这样做,您可以将样式中的 Left 和 Top 设置为一个值。 例如:
<img src="blake.jpg" alt="Mountain View" style="width:141px;height:114px; position:absolute; left:200; top:500;">
关于javascript - 如何移动图像的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36379171/