如何在 Notepad++ 上将 CSS 添加到我的 HTML 代码中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31554557/
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
How to add CSS to my HTML code on Notepad++
提问by Nikki beeeeeeeeeez
So I'm trying to add my CSS code to my HTML code on notepad++ but every time I run it, the only thing I see is my code and not all the content I want about website. How do I fix this?
所以我试图将我的 CSS 代码添加到我在记事本 ++ 上的 HTML 代码中,但每次我运行它时,我唯一看到的是我的代码,而不是我想要的关于网站的所有内容。我该如何解决?
Here is a snip of my html code:
这是我的 html 代码的片段:
<head>
<meta charset="utf-8">
<title>My Website</title>
<link href="cascade.css" rel="stylesheet" type="text/css">
</head>
<h1 style= "text-align:center; color: black;"> Nikki </h1>
<br></br>
//here is a snip of my css code
@charset "utf-8";
/* CSS Document */
nav div {
display: inline;
text-align: center;
width: 18%;
padding: 5px;
}
p
{
text-transform:none;
font-size: 20px;
color: black;
font-family: "proxima-nova";
letter-spacing:1px;
text-align: left;
}
回答by Vasimkhan
Please find your updated code here, This is how you should add/write CSS to HTML :
请在此处找到更新后的代码,这是向 HTML 添加/编写 CSS 的方式:
I would suggest you to move your <style>
tag to <head>
area.
我建议您将<style>
标签移动到<head>
区域。
<html>
<head>
<meta charset="utf-8">
<title>My Website</title>
<link href="cascade.css" rel="stylesheet" type="text/css">
<style type="text/css" >
//here is a snip of my css code
@charset "utf-8";
/* CSS Document */
nav div {
display: inline;
text-align: center;
width: 18%;
padding: 5px;
}
p
{
text-transform:none;
font-size: 20px;
color: black;
font-family: "proxima-nova";
letter-spacing:1px;
text-align: left;
}
</style>
</head>
<body>
<h1 style= "text-align:center; color: black;"> Nikki </h1>
<br>
</body>
</html>
回答by Leo the lion
To apply css you have to put css under tag or you can use external stylesheet..Read more here
要应用 css,您必须将 css 放在标签下,或者您可以使用外部样式表..在这里阅读更多
Please check this example
请检查这个例子
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
nav div
{
display: inline;
text-align: center;
width: 18%;
padding: 5px;
}
p
{
text-transform:none;
font-size: 20px;
color: black;
font-family: "proxima-nova";
letter-spacing:1px;
text-align: left;
}
</style>
</head>
<body>
<div>This is Div.</div>
<p>This is paragraph.</p>
<div style="color:red; font-family:Verdana, Geneva, sans-serif;"> This is Inline CSS Style</div> <!--Inline CSS Style-->
</body>
</html>
You have used css for div and p tag and i have showed you how to use them according to your css. You can also give css in inline way but it just depends on need(mostly avoid it.)
您已经将 css 用于 div 和 p 标签,我已经向您展示了如何根据您的 css 使用它们。您也可以内联方式提供 css,但这仅取决于需要(主要是避免它。)
Hope this will help or let me know if there is any confusion or issue..ty
希望这会有所帮助或让我知道是否有任何混淆或问题..ty