1

How to collapse html table columns into rows? Lets say i have a html table like this

Hello|World
One|Two|Three

and i want all columns to collapsed into row for responsive. Can it be done with CSS?

Hello
World
One
Two
Three
pbu
  • 2,982
  • 8
  • 44
  • 68
  • what code do you have? what have you tried so far? – Jesse Oct 05 '15 at 14:03
  • Basically the fiddle from [this answer](http://stackoverflow.com/a/13861083/1326147) does what you want: http://jsfiddle.net/RnmLF/1/ – Armfoot Oct 05 '15 at 14:05

1 Answers1

3

You need to change from float to display block in your media queries.

@media (max-width: 400px) {
td { 
    float:none; 
    display:block; 
} 
}

Obviously, change your max-width to whatever you like.

You are basically telling you CSS that when the page is being displayed at a certain resolution, in this case 400px, then change the attributes from td to float:none, and display:block;

Hope this helps :)

Rudie Visser
  • 570
  • 6
  • 23
methhead
  • 115
  • 2
  • 12