如何使用CSS摆脱底部边框(How to get rid of th bottom border using css)

编程入门 行业动态 更新时间:2024-10-09 09:13:51
如何使用CSS摆脱底部边框(How to get rid of th bottom border using css)

有没有办法让表列第二列看起来像第一列,同时保留th标签。 分开两者的线仍然必须在那里。

我到目前为止的代码:

.noborders th {
  border-bottom: 0;
}

table {
  border-collapse: collapse
}

#test {
  border-collapse: collapse;
  border: 0;
} 
  
<body>
  <table cellpadding="0" cellspacing="0" width="100%" border="1">
    <th id="test"><b>One</b></th>
    <th><b>Two</b></th>
    <tr>
      <td id="test"></td>
      <td></td>
    </tr>
</body> 
  
 

我希望它看起来像什么

它看起来像什么

Is there a way to make the table column two look like column one while keeping the th tag. The line separating the two still has to be there.

The code I got so far:

.noborders th {
  border-bottom: 0;
}

table {
  border-collapse: collapse
}

#test {
  border-collapse: collapse;
  border: 0;
} 
  
<body>
  <table cellpadding="0" cellspacing="0" width="100%" border="1">
    <th id="test"><b>One</b></th>
    <th><b>Two</b></th>
    <tr>
      <td id="test"></td>
      <td></td>
    </tr>
</body> 
  
 

What I want it to look like

What it looks like

最满意答案

首先,将你的<th>放在<tr>里面......

使用class而不是id (id应该是唯一的)

只需设置border:0到所有td ,然后将border-right应用于.test

th,
td {
  border: 0;
}

td {
  padding: 20px;
}

table {
  border-collapse: collapse
}

.test {
  border-collapse: collapse;
  border-right: 1px solid;
} 
  
<table cellpadding="0" cellspacing="0" width="100%" border="1">
  <tr>
    <th class="test"><b>One</b></th>
    <th><b>Two</b></th>
  </tr>
  <tr>
    <td class="test"></td>
    <td></td>
  </tr>
</table> 
  
 

First, place your <th> inside <tr>...

Use class instead of id(id should be unique)

Just set border:0 to all td, th and apply border-right to .test

th,
td {
  border: 0;
}

td {
  padding: 20px;
}

table {
  border-collapse: collapse
}

.test {
  border-collapse: collapse;
  border-right: 1px solid;
} 
  
<table cellpadding="0" cellspacing="0" width="100%" border="1">
  <tr>
    <th class="test"><b>One</b></th>
    <th><b>Two</b></th>
  </tr>
  <tr>
    <td class="test"></td>
    <td></td>
  </tr>
</table> 
  
 

更多推荐

本文发布于:2023-08-04 19:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1419226.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:边框   如何使用   CSS   rid   border

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!