Heim  >  Artikel  >  Web-Frontend  >  来帮我看看这个html 表格边框颜色怎么弄_html/css_WEB-ITnose

来帮我看看这个html 表格边框颜色怎么弄_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 09:39:591900Durchsuche

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><style type="text/css"><!--.news table td{border:1px solid #F00;}.bac table td{border:1px solid #00F;}--></style><body><table width="658" height="317" border="0" cellspacing="0px" class="bac" style="border-collapse:collapse" align="center" id="t1">  <tr>    <td>1</td>    <td>2</td>  </tr>  <tr>    <td colspan="2"><table width="50%" border="0" align="center" class="news" id="t2">      <tr>        <td>3</td>        <td>4</td>        <td>5</td>      </tr>      <tr>        <td> </td>        <td> </td>        <td> </td>      </tr>      <tr>        <td> </td>        <td> </td>        <td> </td>      </tr>    </table></td>  </tr></table></body></html>

两个表格颜色不一样,为何只有里面那个框显示颜色,我要两个都显示!谢谢!


回复讨论(解决方案)

楼主,你理解的CSS的优先级有误啊,把你的CSS代码改成如下就可以了:

    <style type="text/css">        table.bac td{            border:1px solid #00f;        }        table.news td{            border:1px solid #F00;        }    </style>

或者直接用ID选择器,如下:
     <style type="text/css">        #t1 td{            border:1px solid #00f;        }        #t2 td{            border:1px solid #F00;        }    </style>

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