css里的' + '的意思

时间:2026-02-13 03:55:02

1、1.新建html页面后创建表格,设置表格的背景色为青色,使用浏览器打开新建的html页面;

css里的' + '的意思

2、2.加上#second+ tr{ background-color:#F90;}这行样式后,浏览器只有第三行表格背景变成了橙色。从而可确定css里的‘+’表示元素的下一个元素。

css里的' + '的意思

3、对应代码 

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>css中的 + 号</title>

<style type="text/css">

table{ background-color:#9C6}

#second + tr{ background-color:#F90;}

</style>

</head>

<body>

    <table  width="700" border="1" cellpadding="0" cellspacing="0">

      <tr>

        <td>1</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

      </tr>

      <tr  id="second">

        <td>2</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

      </tr>

      <tr>

        <td>3</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

      </tr>

      <tr>

        <td>4</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

      </tr>

    </table>

</body>

</html>

© 2026 五度知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com