Html 没有填充/边距的引导表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40258014/
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-29 13:58:44  来源:igfitidea点击:

Bootstrap table with no padding/margin?

htmlcsstwitter-bootstrap

提问by Bj?rn C

I have this table:

我有这张表:

<table class="table table-bordered table-condensed col-md-12">
  <thead>
    <tr>
      <td>Input</td>
    </tr>
  </thead
  <tbody>
    <tr>
      <td><input type="text" /></td>
    </tr>
  </tbody>
</table>

I use Bootstrap as my framework and it looks like this:

我使用 Bootstrap 作为我的框架,它看起来像这样:

enter image description here

在此处输入图片说明

How can i stretch the input width & height to fit table cell?

如何拉伸输入宽度和高度以适合表格单元格?

I'm using CSS on input: width: 100%
I've tried CSS on td: padding: 0; margin: 0;

我在输入上使用 CSS:width: 100%
我在 td 上尝试过 CSS:padding: 0; margin: 0;

回答by Bj?rn C

As @Araz comment:

正如@Araz 评论:

tr td{
  padding: 0 !important;
  margin: 0 !important;
}

回答by Charantej Golla

Add padding:0to td. Place your style sheet below bootstrap.css. so !importantis not required. if you use css in inline then !importantis required. .form-controlclass is used to make input width 100%of the cell.

添加padding:0td. 将您的样式表放在下面bootstrap.css。所以!important不是必需的。如果您在内联使用 css,则!important需要。.form-controlclass 用于制作100%单元格的输入宽度。

td{padding:0px !important}
.form-control{border-radius:0px !important;}
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-bordered table-condensed col-md-12">
  <thead>
    <tr>
      <td>Input</td>
    </tr>
  </thead
  <tbody>
    <tr>
      <td><input type="text" class="form-control" /></td>
    </tr>
  </tbody>
</table>