gpt4 book ai didi

css 不会从文件加载

转载 作者:太空宇宙 更新时间:2023-11-04 00:05:53 24 4
gpt4 key购买 nike

我无法从单独的文件加载 .css。

例如,如果我有 html:

<!DOCTYPE html>
<html>
<link href "style.css" rel="stylesheet" type = "text/css">

<head>

</head>

<body>

<h1>My CSS web page!</h1>
<p>Hello world! This is a W3Schools.com example.</p>

</body>
</html>

CSS 没有加载

但是,如果我在同一个 html 文件中有 css,则 css 会正确加载。我究竟做错了什么?

编辑:根据几个人的建议,将 HTML 更改为以下代码。还是没有效果。 sytle.css 与我的源 html 位于同一目录中。

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

<body>

<h1>My CSS web page!</h1>
<p>Hello world! This is a W3Schools.com example.</p>

</body>
</html>

CSS 样式表:

<style>
body
{
background-color:#b0c4de;
}
</style>

最佳答案

您的 link 标签格式不正确,应该位于 head 中(而不是文档的根):

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

应该是(注意 href= 更正):

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

关于css 不会从文件加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14897786/

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