Hello!
There is an element table, in the lines of which there may be a certain number of cells. There may be 3 cells, maybe 5 or 10, but the same number is required in different lines. Well, that is, we represent a normal, human table, as in Excel.
How can I do it through css so that:
- The plate had some fixed width, say 700px;
- Each column had some fixed width, say 300px;
- If the total width of the cells is greater than the width of the table, then a horizontal scroll should appear. Actually, this does not work out for me at all: as long as the width of the columns is evenly reduced if it exceeds the width of the table, setting the overflow property does not help
An illustration of what I want: http://jsfiddle.net/yt6169s1/
<div class="table-wrapper"> <table class="mytable"> <tr> <th class="mytd">1</th> <th class="mytd">2</th> <th class="mytd">3</th> <th class="mytd">4</th> <th class="mytd">5</th> <th class="mytd">6</th> <th class="mytd">7</th> </tr> <tr> <td class="mytd">1</td> <td class="mytd">2</td> <td class="mytd">3</td> <td class="mytd">4</td> <td class="mytd">5</td> <td class="mytd">6</td> <td class="mytd">7</td> </tr> </table> </div> .table-wrapper { width: 700px; } .mytable { border-collapse: collapse; overflow: auto; } .mytd { width: 300px; border: 1px solid black; }
Accordingly, I want the example to follow the link to see only the 1st, 2nd columns 300px wide and the 3rd part 100px wide, while the rest scrolled.
I can do this only through css, without using javascript and without changing the table on the structure of the divs? Compatibility with any old stuff is optional.
Let me try to reformulate it even better: I need some area of limited width (say 700 px) into which several columns of fixed width will fit (i.e., the width of the columns exactly as I indicated, said 200px for each column - and there will be honest 200px for each column ). And if there are more columns than necessary (say 5), then a horizontal scroll will appear.
In other words, I need something like here: http://jsfiddle.net/qr6e61bw/ only with a table and not with divs