Heim  >  Artikel  >  Web-Frontend  >  css 给table设置样式_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-24 11:26:071233Durchsuche

在一个网页中多处使用了表格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样式设置。

 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn