Udoro

Responsive data table CSS

Jun 19th, 2022 (edited)
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.15 KB | None | 0 0
  1. #table_wrapper .ct-div-block{
  2.     display: revert;
  3. }
  4.  
  5. #table_wrapper{
  6.     width: 100%
  7. }
  8.  
  9. #table_wrapper table{
  10.     width: 100%;
  11.     border-collapse: collapse;
  12.    
  13.    
  14. }
  15.  
  16. #table_wrapper th{
  17.     background-color: #0c437a;
  18.     color: white;
  19.     text-align: left;
  20.     padding: 12px 16px;
  21.     border: solid 1px white;
  22. }
  23.  
  24.  
  25. #table_wrapper tr:nth-child(even){
  26.     background-color: #eee;
  27. }
  28.  
  29. #table_wrapper td{
  30.     padding: 8px 16px;
  31. }
  32.  
  33. @media (max-width:479px) {
  34.    
  35.    
  36.     #table_wrapper thead{
  37.         position: absolute;
  38.         top: 0;
  39.         left:0;
  40.         width: 1px;
  41.         height: 1px;
  42.         overflow: hidden;
  43.     }
  44.    
  45.    
  46.    
  47.     #table_wrapper td{
  48.         position: relative;
  49.         text-align: right;
  50.         padding-right: 16px;
  51.         border: solid 1px white;
  52.     }
  53.    
  54.     #table_wrapper td:before{
  55.         content: attr(data-label);
  56.         position: absolute;
  57.         left:0;
  58.         top:0;
  59.         bottom: 0;
  60.         background-color: #0c437a;
  61.         color: white;
  62.         width: auto;
  63.         min-width: 40%;
  64.         font-size: 14px;
  65.         font-weight: 700;
  66.         padding: 8px 16px;
  67.         text-align: left;
  68.        
  69.        
  70.     }
  71.    
  72.     #table_wrapper tr{
  73.         background-color: #eee;
  74.         margin-bottom: 1rem;
  75.     }
  76.    
  77.    
  78.     #table_wrapper td[data-label="Name"]{
  79.         order: -1;
  80.         font-weight: 700;
  81.     }
  82.    
  83.    
  84. }
Add Comment
Please, Sign In to add comment