CSS div样式不能用于HTML

时间:2016-02-06 10:30:31

标签: html css border

我正在尝试使用以下CSS在我的网页中为少数DIV应用边框:

<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="cols.css">
<title>Test</title>
</head>
<body>
<div>
   <div class="column-center">...</div>
   <div class="column-left"><a href="#"> Link 1 </a><br><a href="#"> Link 2 </a><br><a href="#"> Link 3 </a><br><a href="#"> Link 4 </a><br>
</div>
   <div class="column-right"> ... </div>
</div><div id="test"> ... </div>
</body>
</html> 

在我的html中有这样的内容:

display:none

#test中的设置不起作用,我无法弄清楚原因。有什么想法吗?

编辑:如果我将#test的属性放在另一个CSS文件中,它可以正常工作。 编辑:添加相关的HTML代码。

1 个答案:

答案 0 :(得分:3)

你的border-style属性应该是所有边框属性的下一个: 例如:

margin-left:auto;
margin-right:auto;
margin-top:0px;
margin-bottom:0px;
border-left:1px;
border-right:1px;
border-top:0px;
border-bottom:1px;
height: 100px;
border-style:solid;
border-color:#000000;    
background-color: yellow;

并且最好使用速记值:

margin:0 auto;
height: 100px;
border:1px solid #000;
border-top:0;
background: rgb(255,255,0);