CSS 样式表未链接到我的 html 页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20875452/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS stylesheet not linking to my html page
提问by James Dorfman
I have a problem where my css does not affect my html. I made a fiddle hereIt worked when I wasn't trying to connect an external stylesheet and used style tags, Thanks in advance to anyone who can help.
我有一个问题,我的 css 不影响我的 html。我在这里做了一个小提琴 当我没有尝试连接外部样式表并使用样式标签时它起作用了,在此先感谢任何可以提供帮助的人。
btw i tried
顺便说一句,我试过了
<link rel="stylesheet" type="text/css" href="index.css">
and it did not work.
它没有用。
回答by BuddhistBeast
Make sure you are linking it in your 'head' section of the HTML such as this:
确保将它链接到 HTML 的“头部”部分,例如:
<head>
<link href="index.css" type="text/css" rel="stylesheet" />
</head>
Also be sure to close the tag and that the style sheet you are linking is named 'index.css'
还要确保关闭标记,并且您正在链接的样式表名为“index.css”
Edit:
编辑:
HTML is split up into two main section tags: body and head. In a normal HTML page, the structure is like so:
HTML 分为两个主要部分标签:body 和 head。在一个普通的 HTML 页面中,结构是这样的:
<html>
<head>
</head>
<body>
</body>
</html>
The code I referenced at the beginning of this answer should be placed into the head section of the HTML page.
我在这个答案开头引用的代码应该放在 HTML 页面的 head 部分。
回答by David Sawyer
The fact that you are linking to simply index.css
worries me. Is index.css
in your site root? If so, specify that:
你链接到的事实让我很index.css
担心。是否index.css
在您的网站根目录中?如果是,请说明:
<link rel="stylesheet" type="text/css" href="/index.css">
<link rel="stylesheet" type="text/css" href="/index.css">
回答by iamspialeo
As stated also by BuddhistBeast, check to make sure it's in between the head tags:
正如BuddhaBeast 所述,请检查以确保它位于头部标签之间:
<head>
<link href="index.css" type="text/css" rel="stylesheet" />
</head>
Also check that you are referencing it correctly. If it is all in one folder, then
还要检查您是否正确引用了它。如果都在一个文件夹中,那么
<link href="index.css" type="text/css" rel="stylesheet" />
is correct.
是正确的。
If it's in its own folder, named "css" for example, it should be written as:
如果它在它自己的文件夹中,例如名为“css”,它应该写为:
<link href="css/index.css" type="text/css" rel="stylesheet" />
回答by James Dorfman
You put #button
instead of input, #button
in the css.
你把#button
而不是input, #button
在css中。