twitter-bootstrap 引导表宽度

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

Bootstrap Table Width

csshtmltwitter-bootstrap

提问by DUDUM

I have a problem with the table width, I want to auto adjust the width of the table header. How to do this?

我的表格宽度有问题,我想自动调整表格标题的宽度。这个怎么做?

How do I turn this:

我如何转这个:

enter image description here

在此处输入图片说明

Into this:

进入这个:

enter image description here

在此处输入图片说明

回答by d.h.

I assume you want to auto adjust the width of the table cells to its content. In that case you need to set the width of the table to "auto".

我假设您想根据其内容自动调整表格单元格的宽度。在这种情况下,您需要将表格的宽度设置为“自动”。

Example: https://jsfiddle.net/7r9svcu9/

示例:https: //jsfiddle.net/7r9svcu9/

<table style="width: auto;" class="table table-striped table-condensed">...</table>

回答by Emraan Aly

table-response may serve your requirement.

表响应可以满足您的要求。

<table class="table table-responsive">
...
</table>

回答by Kali

try this

试试这个

 <table id="example" class="display nowrap" cellspacing="0" width="100%">

回答by Debugger

<style>
 table { table-layout: fixed; }
 table th, table td { overflow: hidden; }
</style>

<table class="span12">
  <thead>
    <tr>
      <th style="width: 30%">Col 1</th>
      <th style="width: 20%">Col 2</th>
      <th style="width: 10%">Col 3</th>
      <th style="width: 30%">Col 4</th>
      <th style="width: 10%">Col 5</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Val 1</th>
      <td>Val 2</th>
      <td>Val 3</th>
      <td>Val 4</th>
      <td>Val 5</th>
    </tr>
  </tbody>
</table>

For more Reference http://v4-alpha.getbootstrap.com/content/tables/

更多参考http://v4-alpha.getbootstrap.com/content/tables/