gpt4 book ai didi

javascript - 我为一只鸟的 Gif 代码编写了一个代码,让它飞过屏幕,但该图像不可见,即使它位于同一文件夹中

转载 作者:行者123 更新时间:2023-11-28 15:31:38 27 4
gpt4 key购买 nike

嗨,所以我正在尝试学习如何在屏幕的一部分上交叉 gif 图像,除了它不显示我的鸟的图像而只是显示一个带有 x 的黑框之外,代码还可以工作, “鸟的形象”一词。然而我的图像也与我的代码位于同一文件夹中。有什么想法我错了吗?提前致谢。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Project 12</title>
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-1" />
<link rel="stylesheet" href="../js_styles.css" type="text/css" />
<script type="text/javascript">
/* <![CDATA[ */
var topPosition = 150;
var leftPosition = 0;
function flyBird() {
var bird = document.getElementById("bird");
bird.style.left = leftPosition + "px";
bird.style.top = topPosition + "px";
bird.style.visibility = "visible";
topPosition -= 3;
leftPosition += 10;
if (topPosition <= 0) {
topPosition = 150;
leftPosition = 0;
}
}
/* ]]> */
</script>
</head>
<body onload="setInterval('flyBird()', 100);">
<p>
<img src="../bird.gif" id="bird" style="position:
absolute; left: 500px; top: 281px; visibility:hidden" alt="Image of a bird" height="120" width="150" /></p>
<h1>Bird</h1>

<blockquote><p>.</p></blockquote>
<p>&nbsp;</p>
</body>
</html>

最佳答案

my image is also in the same folder as my code

那你为什么要在父文件夹中寻找它?:

<img src="../bird.gif" ...

如果图像位于同一文件夹中,请在那里引用它:

<img src="bird.gif" ...

关于javascript - 我为一只鸟的 Gif 代码编写了一个代码,让它飞过屏幕,但该图像不可见,即使它位于同一文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27130851/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com