由于某些疯狂的原因,我的身体标签根本不起作用。这是唯一一个不起作用的 CSS。我试图了解网站内容背后的背景,并让内容占正文的 80% 左右。这样我就可以在网站的两侧有两个栏,充当边框。堆栈溢出的两侧似乎都有两个白条。
<style type="text/css">
body{
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background-color: #000;
margin: 0;
padding: 0;
color: #000;
}
#content {
font: 14px/1.4 'Times New Roman', sans-serif;
width: 80%;
max-width:1260px;
min-width: 780px;
background-color: #89837A;
margin-left: auto;
margin-right: auto;
}
Run Code Online (Sandbox Code Playgroud)
这是 HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<!--Replace link with good web font you want.<link href='http://fonts.googleapis.com/css?family=PT+Sans+Narrow' rel='stylesheet' type='text/css' /> - See more at: http://www.newthinktank.com/2011/09/how-to-layout-a-website/#sthash.lWAaNgcS.dpuf -->
<link rel="stylesheet" type="text/css" href="CPLS_Stylesheet.css">
<!--<div class='error' style='display:none'>Event Created</div>-->
<title>MyWebsite</title>
</head>
<body>
<div id="content">
HEADER
<div id="contentBackground">
CONTENT
</div><!--End of contentBackground-->
</div> <!--End of content-->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
无论我将正文标签更改为什么颜色,背景始终保持白色。内容的颜色是正确的。
这是:<style type="text/css">在你的 CSS 中还是只是一个错误?
除非您编写该代码时发生意外,否则这不是有效的 CSS。唯一允许的情况是在HTML 文档中使用样式标签来包装 CSS 代码。
好的:
索引.html
<style>
body {
background-color: white;
}
</style>
Run Code Online (Sandbox Code Playgroud)
不行:
样式.css
<style>
body {
background-color: white;
}
Run Code Online (Sandbox Code Playgroud)
由于没有结束标签,看来您不小心从教程中使用<style>HTML 文档中的标签复制了该内容。
| 归档时间: |
|
| 查看次数: |
21003 次 |
| 最近记录: |