gpt4 book ai didi

html - 无法链接到 HTML 中的 CSS 文件

转载 作者:太空宇宙 更新时间:2023-11-03 19:51:07 24 4
gpt4 key购买 nike

我似乎无法在我的 HTML 中链接到我的 CSS 文件。下面是我的 HTML 文件:

<!DOCTYPE html>
<html>

<head>
<title>Welcome.</title>

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

<body>

<p> This paragraph has no ID</p>
<div id="block">
<h2>Hello this is h2 text.</h2>
</div>

<h3> This is a h3 tag with an id that should give it some styling</h3>
<p id="examplep"> This is an example paragraph has an ID that should give it large font.</p>

</body>

</html>

这是 main.css,它与我的 HTML 文件位于同一文件夹中:

body{
background-color: blue;
}
p{
font-size: 50;
}

#block{
position: absolute;
top: 50%;
left: 50%;
margin-top: -150px;
margin-left: -150px;

color: black;
background-color: white;
width: 300px;
height: 300px;
font-family: Arial, Helvetica, sans-serif;
}
#examplep{
font-size: 50px;
}

抱歉格式不正确。无论如何,我相信这是一个链接问题。背景不应该是蓝色的,没有 ID 的段落大小为 50,div 是页面中间带有白色文本的白色框,example 段落大小也是 50 吗?我已经尝试了我所知道的一切来修复它,但我似乎做不到。有帮助吗?

最佳答案

不要将其包含在样式标签 中。简单的写

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

关于html - 无法链接到 HTML 中的 CSS 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25541119/

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