使用表格边框的类时,如何使某些表格单元格边框消失?

唐阮

我的目标是消除特定表格单元格(td的顶部和底部边框我能够删除内部边框,但顶部和底部边框仍然存在。

这是我的html代码

<div class="container">
  <div class="row">
    <table class="table table-bordered">
        <tbody>
            <tr>
                <th class="w-8">Label 1</th>
                <td class="w-40"><input type="text"></td>
                <td class="w-2 no-top-bottom"></td>
                <th class="w-8">Label 2</th>
                <td class="w-40"><input type="text"></td>
            </tr>
            <tr>
                <th class="w-8">Label 1</th>
                <td class="w-40"><input type="text"></td>
                <td class="w-2 no-top-bottom"></td>
                <th class="w-8">Label 2</th>
                <td class="w-40"><input type="text"></td>
            </tr>
            <tr>
                <th class="w-8">Label 1</th>
                <td class="w-40"><input type="text"></td>
                <td class="w-2 no-top-bottom"></td>
                <th class="w-8">Label 2</th>
                <td class="w-40"><input type="text"></td>
            </tr>
            <tr>
                <th class="w-8">Label 1</th>
                <td class="w-40"><input type="text"></td>
                <td class="w-2 no-top-bottom"></td>
                <th class="w-8">Label 2</th>
                <td class="w-40"><input type="text"></td>
            </tr>
        </tbody>
    </table>
  </div>
</div>

这是我的CSS样式

table td {
    position: relative;
}

table  input {

    height: 100%;
    width: 100%;
    
}

.w-4 {
    width: 4%;
}

.w-8 {
    width: 8%;
}

.w-10 {
    width: 10%;
}

.w-40 {
    width: 40%;
}

.no-top-bottom {
    border-top: none !important;
    border-bottom: none !important;
}

我的问题是td顶部和底部元素仍然具有边框。就像下面的图片一样。我也想删除黄色标记的边框。我的问题

蓬松的小猫

您正在从单元格中删除边框,但是.table-bordered该类还在上添加了边框<table>

从表格中删除边框将起作用:

table.table-bordered { border:none;}

.table-bordered课程将仍然添加边框的所有单元格,但不会强迫桌子周围的外边框,让你的.no-top-bottomCSS将现在的工作。

工作片段:

table.table-bordered { border:none;}

table td {
    position: relative;
}

table  input {

    height: 100%;
    width: 100%;
    
}

.w-4 {
    width: 4%;
}

.w-8 {
    width: 8%;
}

.w-10 {
    width: 10%;
}

.w-40 {
    width: 40%;
}

.no-top-bottom {
    border-top: none !important;
    border-bottom: none !important;
}
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
<div class="container">
  <div class="row">
    <table class="table table-bordered">
        <tbody>
            <tr>
                <th class="w-8">Label 1</th>
                <td class="w-40"><input type="text"></td>
                <td class="w-2 no-top-bottom"></td>
                <th class="w-8">Label 2</th>
                <td class="w-40"><input type="text"></td>
            </tr>
            <tr>
                <th class="w-8">Label 1</th>
                <td class="w-40"><input type="text"></td>
                <td class="w-2 no-top-bottom"></td>
                <th class="w-8">Label 2</th>
                <td class="w-40"><input type="text"></td>
            </tr>
            <tr>
                <th class="w-8">Label 1</th>
                <td class="w-40"><input type="text"></td>
                <td class="w-2 no-top-bottom"></td>
                <th class="w-8">Label 2</th>
                <td class="w-40"><input type="text"></td>
            </tr>
            <tr>
                <th class="w-8">Label 1</th>
                <td class="w-40"><input type="text"></td>
                <td class="w-2 no-top-bottom"></td>
                <th class="w-8">Label 2</th>
                <td class="w-40"><input type="text"></td>
            </tr>
        </tbody>
    </table>
  </div>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

表格单元格的边框颜色变化

来自分类Dev

如何防止表格单元格边框被单元格图像剪切?

来自分类Dev

在LibreOffice中的表格边框上创建新单元格

来自分类Dev

表格单元格带有闪烁的边框

来自分类Dev

打印时无法显示表格和单元格边框

来自分类Dev

表格周围边框,但单元格周围

来自分类Dev

删除HTML表格单元格的顶部边框

来自分类Dev

有表格边框,但没有单元格边框

来自分类Dev

如何删除表格中单元格的边框?

来自分类Dev

如何设置表格边框小于单元格高度

来自分类Dev

CSS:表格单元格上无上下边框

来自分类Dev

如何在HTML表格中强制使用单元格的边框颜色

来自分类Dev

使表格单元格的边框为表格宽度的100%

来自分类Dev

表格单元格的边框颜色变化

来自分类Dev

如何防止表格单元格边框被单元格图像剪切?

来自分类Dev

在LibreOffice中的表格边框上创建新单元格

来自分类Dev

表格单元格带有闪烁的边框

来自分类Dev

表格周围有边框,但没有单元格

来自分类Dev

在HTML表格中隐藏单元格边框

来自分类Dev

单个表格单元格CSS上的黑色边框

来自分类Dev

HTML,从表格的左上角单元格删除边框

来自分类Dev

通过CSS边框化表格中的某些单元格

来自分类Dev

悬停时向表格单元格添加左边框

来自分类Dev

使表格单元格的边框为表格宽度的100%

来自分类Dev

使用“显示:表格单元格”的不良边框行为

来自分类Dev

不需要的表格单元格边框

来自分类Dev

如何为表格单元格边框的角指定上/下边框而不是左/右边框的颜色

来自分类Dev

如何从表格单元格中删除填充和边框?

来自分类Dev

如何调整表格单元格边框的样式?

Related 相关文章

热门标签

归档