cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <html>
  <head>
    <title>table max-width</title>
  </head>
  <body>
    <div class="col-sm-12 well">
      <h3>例子一,不进行任何换行,td 自动扩充长度,故高度只有一行</h3>
      <table class="table-bordered table-hover table-striped table-out">
        <thead>
          <tr>
            <th style="width: 10%;">1</th>
            <th style="width: 30%;">2</th>
            <th style="width: 30%;">3</th>
            <th style="width: 30%;">4</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_overflow_</td>
            <td>xxx</td>
            <td>xxx</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>xxx</td>
            <td>xxx</td>
            <td>xxx</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td>xxx</td>
            <td>xxx</td>
            <td>xxx</td>
          </tr>
      </tbody>
      </table>
    </div>

    <div class="col-sm-12 well">      
      <h3>例子二,进行强制换行,td 继承父级元素的长度,高度自动拓展</h3>
      <table class="table-bordered table-hover table-striped table-warp">
        <thead>
          <tr>
            <th style="width: 10%;">1</th>
            <th style="width: 30%;">2</th>
            <th style="width: 30%;">3</th>
            <th style="width: 30%;">4</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td> warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_
                 </td>
            <td>xxx</td>
            <td>xxx</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>xxx</td>
            <td>xxx</td>
            <td>xxx</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td>xxx</td>
            <td>xxx</td>
            <td>xxx</td>
          </tr>
      </tbody>
      </table>
    </div>

    <div class="col-sm-12 well">      
      <h3>例子三,不进行任何换行,td 继承父级元素的长度</h3>
      <table class="table-bordered table-hover table-striped table-ellipsis">
        <thead>
          <tr>
            <th style="width: 10%;">1</th>
            <th style="width: 30%;">2</th>
            <th style="width: 30%;">3</th>
            <th style="width: 30%;">4</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td style="height: 1em;" title="warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_">
              <div class="td-overflow-container">
                <div> warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_warp_
                </div>
              </div> </td>
            <td>xxx</td>
            <td>xxx</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>xxx</td>
            <td>xxx</td>
            <td>xxx</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td>xxx</td>
            <td>xxx</td>
            <td>xxx</td>
          </tr>
      </tbody>
      </table>
    </div>
  </body>
</html>
            
          
!
            
              html, body {
  width: 100%;
}
body {
  font-size: 160%;
  line-height: 1.42em;
}
table {
  width: 100%;
  margin: 1em;
  &.table-warp {
    word-wrap: break-word;
    word-break: break-all;
  }
}

.td-overflow-container {
  // 必须定义上级 td 的高度。不然就没法获取高度。
  height: 100%;
  position: relative;
}
.td-overflow {
  white-space: nowrap;
  position: absolute;
  text-overflow: ellipsis;
  width: 100%;
  height: 100%;
  overflow: hidden;
}



            
          
!
999px
Loading ..................

Console