CSS Bootstrap table-bordered 移除右、左边框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20821662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:26:34  来源:igfitidea点击:

Bootstrap table-bordered remove right, left borders

csstwitter-bootstrap

提问by Snowman

I'm using a table like so:

我正在使用这样的表格:

<table class="table table-hover table-bordered">

This table creates cells that have borders on all four sides. What I want is to remove the left and right borders, but keep top and bottom.

此表创建的单元格在所有四个边上都有边框。我想要的是删除左右边框,但保留顶部和底部。

I tried:

我试过:

.table thead>tr>th,.table tbody>tr>th,.table tfoot>tr>th,.table thead>tr>td,.table tbody>tr>td,.table tfoot>tr>td{
   border-right:none;
   border-left: none;
   border-bottom: 1px solid red;
}

However, this does not remove the left or right borders, but it does apply a red bottom border, so I know it's at least processing this CSS, but with no effect for removing borders.

但是,这不会删除左边框或右边框,但它确实应用了红色底部边框,所以我知道它至少正在处理此 CSS,但对删除边框没有效果。

Any ideas?

有任何想法吗?

回答by Christina

Change this: <table class="table table-hover table-bordered">

改变这个: <table class="table table-hover table-bordered">

To this: <table class="table table-hover">

对此: <table class="table table-hover">

And then add this css:

然后添加这个css:

.table {
  border: 1px solid #dddddd;
}

However, if you want to do it the way you're doing it, the css is:

但是,如果您想按照自己的方式进行操作,则 css 是:

.table-bordered > thead > tr > th,
.table-bordered > tbody > tr > th,
.table-bordered > tfoot > tr > th,
.table-bordered > thead > tr > td,
.table-bordered > tbody > tr > td,
.table-bordered > tfoot > tr > td {
  border: 1px solid #dddddd;
  border-right-width:0px;
  border-left-width:0px;
}

DEMO: http://jsbin.com/IbebIpob/2/edit

演示:http: //jsbin.com/IbebIpob/2/edit