Home > Web Front-end > HTML Tutorial > 来帮我看看这个html 表格边框颜色怎么弄_html/css_WEB-ITnose

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

WBOY
Release: 2016-06-21 09:39:59
Original
1980 people have browsed it

<!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>
Copy after login

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


回复讨论(解决方案)

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

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

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template