如何在CSS中添加几个td和tr

时间:2012-11-08 20:24:19

标签: html css html-table row

我有一个看起来像这样的CSS:

CSS

table {   
 width: 100%;
 font-family: calibri;
 word-wrap:break-word;
 margin-left: 0; 
 font-size: 1.1em;
 border-collapse: separate;
 border-spacing: 1px;      
}

td {  
 text-transform: none;
 font-weight: bold;
 line-height: 115%;
 word-wrap:break-word;  
 vertical-align: middle; 
 padding: 2px 10px 0 3px ; 
 border-radius: 2px;
 border: 1px solid #6A797F;        
}   

tr:nth-child(odd){
 background-color: #a9c6c9; 
}

tr:nth-child(even){
 background-color: #d4e3e5;
}

如何添加单独的<table><td>&amp; {CSS}文件中的<tr>我可以更改样式以适应特定页面设计的目的。我试过这个解决方案,但它不起作用:

.members_col1 tr td{
  text-transform: none;
  line-height: 115%;
  word-wrap: break-word;  
  vertical-align: left; 
}

.member_col1<div>,其中包含<table>我要为其添加一组新样式。

3 个答案:

答案 0 :(得分:1)

在表格中使用属性ID或类,然后在css中将它们作为选择器覆盖,例如:

<table id="another-table">...

css
#another-table{
....
}

<table class="tables">...
<table class="tables">...

css
.tables{
...
}

答案 1 :(得分:0)

在你的html中使用它:

<table class="newTable">
...
</table>

并使用此CSS:

.newTable tr td{
   text-transform: none !important;
   line-height: 115% !important;
   word-wrap:break-word !important;  
   vertical-align: left !important; 
   }

答案 2 :(得分:0)

您的解决方案应该有效。可能不起作用的是您提供的价值。

.members_col1 tr td{
   text-transform: none;
   line-height: 115%;
   word-wrap:break-word;  
   vertical-align: left; 
}

text-transformline-heightword-wrap值与默认值相同。

vertical-align属性使用不正确 - left不是有效值。也许你的意思是使用text-align属性?

相关问题