[英]Visual Studio Web Site CSS Won't Apply
I am, for the first time, trying to create a website in VS2013. 我是第一次尝试在VS2013中创建网站。 I created a new website, and set
Home.html
as the startup page. 我创建了一个新网站,并将
Home.html
设置为启动页面。 And that works just fine. 而且效果很好。 Then I added a file called
Home.css
to be the stylesheet for Home.html
. 然后,我添加了一个名为
Home.css
的文件作为Home.html
的样式表。 For my HTML I have: 对于我的HTML,我有:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
</head>
<body>
<div class="header-div">
Testing!
</div>
</body>
</html>
And my CSS is: 我的CSS是:
.header-div {
background-color: black;
width: 100%;
height: 200px;
}
The header-div
class comes up in my IntelliSense and everything, but it won't actually apply to the div
. header-div
类出现在我的IntelliSense和所有内容中,但实际上不适用于div
。 What am I doing wrong? 我究竟做错了什么?
You should link the css : add this part to head. 您应该链接CSS:将此部分添加到头部。
<link rel="stylesheet" href="Home.css" />
So your code would be : 因此您的代码将是:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="Home.css" />
<title>Test</title>
</head>
<body>
<div class="header-div">
Testing!
</div>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.