我的表实体如何继承表类?

时间:2013-06-18 17:30:47

标签: html css css3

这是我的css:

table.mytable { 
    border-collapse: collapse;
    width: 50%;
    margin: 24px;
    font-size: 1.1em;
}

caption.mytable { 
    font-size: larger; 
    margin: 5px auto; 
}

th.mytable, td.mytable, thead.mytable { 
    background: #3e83c9;
    color: #fff;
    font-weight: bold;
    padding: 2px 11px;
    text-align: left;
    border-right: 1px solid #fff;
    line-height: 1.2;
}

tr.mytable:nth-child(odd) { 
    background: #ecf6fc; 
}

tr.mytable:hover { 
    background: #bcd4ec; 
} 

td.mytable { 
    padding: 6px 11px;
    border-bottom: 1px solid #95bce2;
    vertical-align: top;
}

css样式运行正常,我遇到的问题是在我的html中我必须为每个<tr><td><th>等分配一个类.Is有一种方法,我只需要将类分配给表?我是否必须修改我的css代码?

谢谢!

1 个答案:

答案 0 :(得分:0)

应该是这样的:

table.mytable th, table.mytable td, table.mytable thead{
    background: #3e83c9;
    color: #fff;
    font-weight: bold;
    padding: 2px 11px;
    text-align: left;
    border-right: 1px solid #fff;
    line-height: 1.2;
}

请参阅CSS selectors