bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

fixed table column width. How?

Open viruthagiri opened this issue 14 years ago • 13 comments

Can anyone tell me how to give fixed table column width. I have five columns. I want like 30%,20%,10%,30%,10% Can anyone help me? Thanks

viruthagiri avatar Dec 28 '11 23:12 viruthagiri

<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>

jasny avatar Dec 29 '11 00:12 jasny

@jasny Thanks.. Its working. But i still have problem. Its not working when i have lengthy text in the cell. Is there a way to hide the overflow text?.I tried overflow:hidden; But its not working.

viruthagiri avatar Dec 29 '11 01:12 viruthagiri

@jasny Thanks once again. I added style="table-layout: fixed;" and applied overflow:hidden; in the td. Now its working. :) Thanks

viruthagiri avatar Dec 29 '11 01:12 viruthagiri

@Viruthagiri I've changed the example. Have a look.

@fat This isn't really an issue, please close it.

jasny avatar Dec 29 '11 01:12 jasny

Thanks

viruthagiri avatar Dec 29 '11 02:12 viruthagiri

thanks for the help @jasny!

fat avatar Jan 02 '12 23:01 fat

@jasny thanks!

enlare avatar Jan 21 '13 06:01 enlare

Finally found an answer!! Thanks !!

canfas avatar Mar 07 '13 05:03 canfas

Thanks

moonstruck avatar Jul 09 '13 19:07 moonstruck

Thanks @jasny ! Was looking out for this answer for quite a while.

suyashtripathi avatar Aug 01 '13 06:08 suyashtripathi

Same here, thanks @jasny. I spent 15 minutes digging through BS determined to find a helper class that did this... guess i'll make my own haha.

mostlyharmless2024 avatar Aug 01 '13 13:08 mostlyharmless2024

Thanks

sgsheg avatar Mar 12 '14 06:03 sgsheg

thanks !

natuanorg avatar Jul 15 '14 04:07 natuanorg