1

I don't understand why is table cells width wider than cell's content.

I would like to have width of column Artikel aligned with content. What I've already tried is set th width - but this is fixed and it doesn't align with content. Is there any other solution?

My example is here

enter image description here

FrenkyB
  • 6,625
  • 14
  • 67
  • 114
  • Add the class shown in the answer [here](https://stackoverflow.com/questions/26983301/how-to-make-a-table-column-be-a-minimum-width). This will force the column to be the minimum width possible - specified by the content of that column – Michael Hancock Oct 03 '17 at 14:32
  • I've tried this on my example and it doesn't work. – FrenkyB Oct 03 '17 at 14:39

1 Answers1

2

That is because of the class table from bootstrap.min.css which is as below.

.table {
    width: 100%;
    margin-bottom: 20px;
}

So if you remove the table class the results is as needed.

Codepen Demo

Naren Murali
  • 19,250
  • 3
  • 27
  • 54
  • Thanks, it works. How to make table width 100% and at the same time make cells width align with content? (table width should be 100% inside given div with class='col-sm-12') – FrenkyB Oct 03 '17 at 15:10
  • @FrenkyB If the table width is 100%, then obviously there will be extra space. just think about it, it would be better if you just center the table, if you don't want that space! – Naren Murali Oct 03 '17 at 15:12