javascript - 如何移动图像的位置?

标签 javascript html css

我在我的网站主页上放了一张图片,但我想移动图片的位置而不是操纵图片的像素。我确定它与填充或边距有关,但是我不确定如何将它实现到我的程序中。这是我的代码:

<!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/

相关文章:

javascript - 密码保护页面

php - Javascript/jquery 在 IE8 中不工作

javascript - Highlight.js 在 Haskell 上失败了?

javascript - 从客户端调用 node.js 服务时的竞争条件

javascript - 为什么将匿名 JavaScript 函数声明为函数参数?

html - IE7 li 图像和文本问题 - 文本。快工作了

html - 没有 MVC 经验的设计师如何设计 Web 应用程序?

javascript - 有没有办法在 Pikaday 中取消选择日期?

javascript - 将复杂的 SVG 元素附加到选区

javascript - jQuery 从我的 Web 文件夹中的文本文件读取并附加到 div