To make the column expand smoothly instead of snapping into a new width with media queries:
table{
max-width: 125px;
}
td{
min-width: 25px;
}
td:nth-child(1){
width:40%; // Translates to roughly 50px
}
This will allow the first column to expand with the available window space.
http://jsfiddle.net/RUNcm/
This works because if the table goes below 125px
in width, the min-width
of td kicks in and keeps the first child from going below 25px
.
On the other hand, if the table is larger than 100px
in width (because the user expanded the browser window), 40%
width will allow it to go up to 52px
but no further. (that's what max-width 125px;
helps moderate).
Note on nth-child
: As Jay Na stated, nth-child
has less browser support than first-child
. You might want to look into using the first-child
pseudo-class instead.
MDN Docs
nth-child
https://developer.mozilla.org/en-US/docs/CSS/:nth-child
first-child
https://developer.mozilla.org/en-US/docs/CSS/:first-child