<分区>
<分区>
我的 CSS 有问题。在这里:
Div main 的 CSS:
.main {background: #E6E6E6; padding: 2em; heigh:100%;}
链接的 CSS:
a { color: #8D0D19; }
main 的 HTML:
<div class="main">
<h3>Welcome</h3><br /> ...More Content Here....
<h3><a href="new.php">New</a></h3>
链接的颜色是酒红色。当页面上出现链接时,页面上的整个文本都会变成酒红色。
我还为 .main
添加了颜色属性但它没有用。我也尝试制作 a
, .main a
但这也没有用。
那么我应该怎么做才能让我的文本保持黑色并且只有链接是勃艮第的?
顺便说一句,我不太了解 CSS。如果你能给我推荐一些 CSS 入门的网站、培训或书籍,那就太好了。
谢谢。
更新: 这是整个 CSS 代码:
* { margin: 0; }
html { height: 100%; width: 100%; }
body { height: 100%; width: 100%; margin: 0; padding: 0; border: 0; background: #E6E6E6; font: 13px/15px Verdana,Arial,Helvetica,sans-serif; }
.wrapper { min-height: 100%; height: auto !important; height: 100%; margin: 0 auto -42px; }
.header { height: 70px; text-align: left; background: #1A446C; color: #D4E6F4; }
.header h1 { padding: 1em; margin: 0;} .header a {position: absolute; right:0; top: 0px; text-align: right; padding: 1.25em; margin: 0; color: >#D4E6F4; text-decoration:none;}
.main {color: #000000; background: #E6E6E6; padding: 2em; heigh:100%;} .main a {color: #8D0D19;}
.footer { height:10px; text-align: center; padding: 7px; background: #1A446C; color: #D4E6F4; position:absolute; bottom:0; right:0; left:0; }
img { border: none; }
table, tr, td, tr { border-collapse: collapse; vertical-align: top; text-align: left; font: 13px/15px Verdana,Arial,Helvetica,sans-serif; }
table.bordered tr th, table.bordered tr td { border: 1px solid #000000; }
这是 HTML 代码:
<html> <head>
<link href="style.css" rel="stylesheet" type="text/css" /> </head> <body>
<div class="wrapper">
<div class="header">
<h1>Header</h1><h2><a href="login.php?logout=1">Logout<a/></h2>
</div>
<div class="main"><h3>HTML Text Here....</h3><br /><br /> <h3><a href="new.php" >New</a></h3> </div> </div> <div class="footer">
<p>Copyright © 2011</p>
</div> </body> </html>
更新:在此处测试:http://jsfiddle.net/hhgGE/
最佳答案
更新:
该错误是由 .header 中的拼写错误引起的 <a/>
结束标签 - 应该是 </a>
.
这是一个实时链接: http://jsfiddle.net/RF9cC/1/
上一个:
听起来颜色是从其他地方继承的,或者您没有关闭 </a>
标记正确?你可以这样做:
.main{
color:#000;
}
.main a:link{
color:#8D0D19;
}
这应该将 DIV .main 中的所有文本样式设置为黑色,但将任何链接设置为紫红色。
Robert Schifreen 的这本电子书是构建网站的一个很好(且深入)的引用资料: http://www.the-web-book.com/browse/index.html
它包含有关网页设计的几乎所有知识的详细信息。
关于html - CSS Problem link(a) 属性控制文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5725957/