Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 应用表格单元格边框_Html_Css - Fatal编程技术网

Html 应用表格单元格边框

Html 应用表格单元格边框,html,css,Html,Css,我有一个类为“productsTable”的HTML表。我想给表中的每个单元格加一个边框。现在,我在样式表中尝试了以下内容,但这两种方法都没有成功。我做错了什么?多谢各位 td.productsTable { border: 1px dotted #999999; } .productsTable td { border: 1px dotted #999999; } HTML: 我们提供: 免费电子电话 个人的 Pro PBX 定价 自由的 每月3英镑 从每月5英镑起 这样

我有一个类为“productsTable”的HTML表。我想给表中的每个单元格加一个边框。现在,我在样式表中尝试了以下内容,但这两种方法都没有成功。我做错了什么?多谢各位

td.productsTable
{
    border: 1px dotted #999999;
}

.productsTable td
{
    border: 1px dotted #999999;
}
HTML:


我们提供:
免费电子电话
个人的
Pro PBX
定价
自由的
每月3英镑
从每月5英镑起
这样写:

.products td
{
    border: 1px dotted #999999;
}
HTML

<table class="products">
 <tr>
  <td></td>
</tr>
</table>

td.productsTable
无法工作,因为您没有
类的
元素

但是,您的第二个CSS规则
.productsTable td
,这个将起作用,因为您确实有
元素,这些元素的父元素具有类
productsTable

我很快就搞定了这个,你可以看到它工作正常:

td{
边框:1个点#999;
}

我们提供:
免费电子电话
个人的
Pro PBX
定价
自由的
每月3英镑
从每月5英镑起
我想给表中的每个单元格加一个边框

我的理解是你想要这样的细胞边界:

.products td
{
    border: 1px dotted #999999;
}

这是你想要的

使用以下CSS:


希望这有帮助。

下面的代码执行以下操作:- 1.为td提供单边框 2.将边框与桌子分开

环境:- 在FF 34.0上工作

未测试html6:- 要使用html6运行它,请尝试使用html:x,例如html:head、html:title等

<!DOCTYPE html>
<html>
<head>
    <script>
    </script>
    <title>Welcome to the jungle</title>
    <style>
.table_main {
        border-top-style: ridge;
        border-bottom-style: ridge;
        border-left-style: ridge;
        border-right-style: ridge;
        border-color: red;
        border-width: 3px;
      }

.table_main td {
    background: #A38055;    
    border-right: solid 1px white ;
    border-bottom: 1px solid white;
    text-align: center;
}

.table_main th {
    background: #DCDCDC;
    border-right: solid 1px white ;
    border-bottom: 1px solid white;
    text-align: center;
}

  </style>
</head>
  <body>
    <h1>Welcome to the jungle</h1>
    <table class="table_main" width="400" align="center" border="0" cellspacing="0" cellpadding="0">
     <thead>       <th>THead1</th> <th>THead2</th> <th>THead3</th>
     </thead> 
      <tbody>
        <tr> <td>A</td> <td>B</td> <td>C</td> </tr>
        <tr> <td>X</td> <td>Y</td> <td>Z</td> </tr>
        <tr> <td>Xena</td> <td>Yoda</td> <td>Zohan</td> </tr>
      </tbody>
    </table>

  </body>
</html>

欢迎来到丛林
.表_main{
边顶样式:脊;
边框底部样式:脊状;
边框左侧样式:脊状;
右边框样式:脊状;
边框颜色:红色;
边框宽度:3倍;
}
.table_main td{
背景:#A38055;
右边框:纯色1px白色;
边框底部:1px纯白;
文本对齐:居中;
}
.表(四){
背景:#DCDC;
右边框:纯色1px白色;
边框底部:1px纯白;
文本对齐:居中;
}
欢迎来到丛林
THead1 THead2 THead3
A、B、C
X Y Z
泽娜·尤达·佐汉

但这会影响所有td,这不是他想要的。我同意你的观点,但他没有展示他的HTML结构,所以很难理解他的HTML结构。如果一个问题无法合理回答,不要回答它。@Quentin如果你看到这个问题,你就会知道OP做错了什么。给我看看你的html代码,也看看这个表。如果其他条件都相同,这两个都可以……只要你的标记与你正在写的选择器匹配。如果不起作用,则可能是您的标记不匹配,或者您有其他样式覆盖这些样式。因为我们两个都看不见,所以说不出是哪个。谢谢,它起作用了。感谢您的帮助…我认为文件只是花了很长时间才到达服务器可能…真的浪费了我的时间像这样的问题。
<!DOCTYPE html>
<html>
<head>
    <script>
    </script>
    <title>Welcome to the jungle</title>
    <style>
.table_main {
        border-top-style: ridge;
        border-bottom-style: ridge;
        border-left-style: ridge;
        border-right-style: ridge;
        border-color: red;
        border-width: 3px;
      }

.table_main td {
    background: #A38055;    
    border-right: solid 1px white ;
    border-bottom: 1px solid white;
    text-align: center;
}

.table_main th {
    background: #DCDCDC;
    border-right: solid 1px white ;
    border-bottom: 1px solid white;
    text-align: center;
}

  </style>
</head>
  <body>
    <h1>Welcome to the jungle</h1>
    <table class="table_main" width="400" align="center" border="0" cellspacing="0" cellpadding="0">
     <thead>       <th>THead1</th> <th>THead2</th> <th>THead3</th>
     </thead> 
      <tbody>
        <tr> <td>A</td> <td>B</td> <td>C</td> </tr>
        <tr> <td>X</td> <td>Y</td> <td>Z</td> </tr>
        <tr> <td>Xena</td> <td>Yoda</td> <td>Zohan</td> </tr>
      </tbody>
    </table>

  </body>
</html>