gpt4 book ai didi

javascript - CSS 在 Firefox 中不工作(或 HTML 显示为简单文本)

转载 作者:行者123 更新时间:2023-11-30 16:11:39 25 4
gpt4 key购买 nike

这是一个简单的网页,比较两张照片并更改未被点击的照片。该代码在 Chrome 中完美运行,但在 Firefox 中,HTML 显示为简单文本,甚至链接也不起作用。代码:-

* {
box-sizing: border-box;
}
html {
height: 100%;
}
body {
height: 100%;
margin: 0px;
padding: 0px;
}
header {
padding: 5px;
background-color: red;
color: white;
text-align: center;
font-family: Magneto;
-webkit-box-shadow: 4px 4px 7px grey;
-ms-box-shadow: 4px 4px 7px grey;
-moz-box-shadow: 4px 4px 7px grey;
-o-box-shadow: 4px 4px 7px grey;
box-shadow: 4px 4px 7px grey;
}
main {
margin: 10px;
}
#ques {
font-family: Cooper;
font-size: 125%;
font-weight: normal;
}
#imageContainer {
margin: auto;
text-align: center;
display: block;
}
.image {
width: 20%;
height: auto;
display: inline-block;
border: 2px solid black;
padding: 3px;
}
#or {
display: inline-block;
font-family: arial;
}
#leftImage {
margin-right: 10px;
}
#rightImage {
margin-left: 10px;
}
@media screen and (max-width: 600px) {
.image {
width: 30%;
}
}
aside {
font-size: 105%;
text-align: center;
margin: 20px 5px 5px 5px;
}
<!DOCTYPE html>
<html lang="en-US" dir="ltr">

<head>
<link rel="stylesheet" type="text/css" href="D:/staticFbs.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
var x = 1;
var y = 2;
$(document).ready(function() {
$("#leftImage").click(function() {
x = x + 2;
$("#rightImage").attr("src", "D:/staticFbp/boys/" + (x) + ".jpg");
if (x > y) {
var temp = y;
y = x;
x = temp;
};
});
$("#rightImage").click(function() {
y = y + 1;
$("#leftImage").attr("src", "D:/staticFbp/boys/" + (y) + ".jpg");
if (x > y) {
var temp = y;
y = x;
x = temp;
};
if (y > (x + 1)) {
x = x + 1;
};
});
});
</script>
</head>

<body>
<header>
<h1><abbr title="Ranking fun">SJSBook</abbr></h1>
</header>
<main>
<h3 id="ques">Q: Who is better?</h3>
<div id="imageContainer">
<img src="D:/staticFbp/boys/1.jpg" alt="Contestant 1" class="image" id="leftImage" />
<div id="or"><b>OR</b>
</div>
<img src="D:/staticFbp/boys/2.jpg" alt="Contestant 2" class="image" id="rightImage" />
</div>
<aside><em>Feel free as your votes will be confidential.</em>
</aside>
</main>
</body>

</html>

Preview of webpage in firefox

最佳答案

使用相对路径而不是绝对路径:

<link rel="stylesheet" type="text/css" href="staticFbs.css" />

关于javascript - CSS 在 Firefox 中不工作(或 HTML 显示为简单文本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36149271/

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