Home  >  Article  >  Web Front-end  >  css 给table设置样式_html/css_WEB-ITnose

css 给table设置样式_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:26:071232browse

在一个网页中多处使用了表格table标签,这个时候给指定的表格对象设置样式依然可以通过CSS进行控制设置。其实有时我们这样思考将table标签当作DIV标签来布局设置CSS,就变得简单多了。

 

对table设置样式

通过对应table父级样式命名指定对象内table样式

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>指定对象内table设置样式</title> <style> .manongjc{ width:400px} .manongjc table{ background:#CCC; color:#F00} .manongjc table td{ background:#FFF} </style> </head> <body> <div class="manongjc"> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td>内容一</td> <td>内容一</td> <td>内容一</td> </tr> <tr> <td>内容二</td> <td>内容</td> <td>内容</td> </tr> </table> </div> </body> </html> 

以上通过父级指定table和td进行CSS样式设置。

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn