Guest User

Untitled

a guest
May 26th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. /**
  2. * Responsive tables with element()
  3. * Pros: No markup changes, works with normal table markup, no content duplication
  4. * Cons: element() is only implemented in Firefox :(
  5. */
  6.  
  7. @media (max-width: 600px) {
  8. table, tr, td, th, thead, tbody {
  9. display: block;
  10. }
  11.  
  12. thead {
  13. float: left;
  14. margin-left: -99in;
  15. }
  16.  
  17. tbody tr {
  18. margin: .2em 0;
  19. padding-left: 4em;
  20. }
  21.  
  22. td::before {
  23. content: '';
  24. float: left;
  25. margin-left: -4em;
  26. height: 2em;
  27. width: 4em;
  28. }
  29.  
  30. td:nth-child(1)::before {
  31. background: -moz-element(#header0) no-repeat;
  32. background: element(#header0) no-repeat;
  33. }
  34. td:nth-child(2)::before {
  35. background: -moz-element(#header1) no-repeat;
  36. background: element(#header1) no-repeat;
  37. }
  38. td:nth-child(3)::before {
  39. background: -moz-element(#header2) no-repeat;
  40. background: element(#header2) no-repeat;
  41. }
  42. td:nth-child(4)::before {
  43. background: -moz-element(#header3) no-repeat;
  44. background: element(#header3) no-repeat;
  45. }
  46. td:nth-child(5)::before {
  47. background: -moz-element(#header4) no-repeat;
  48. background: element(#header4) no-repeat;
  49. }
  50.  
  51. th {
  52. text-align: left;
  53. }
  54.  
  55. td:not(:first-child) {
  56. border-top: none;
  57. }
  58. }
  59.  
  60. /* Just styling after this */
  61. body {
  62. font: 150%/1.6 Helvetica Neue, sans-serif;
  63. }
  64.  
  65. table {
  66. border-spacing: 0;
  67. border-collapse: collapse;
  68. }
  69.  
  70. td, th {
  71. padding: 0 .3em;
  72. }
  73.  
  74. td {
  75. border: 1px solid rgba(0,0,0,.1);
  76. }
Add Comment
Please, Sign In to add comment