chihung
5/3/2019 - 3:09 AM

horizontal table responsive

horizontal table responsive

<table class="table table-horizontal table-price">
                            <thead>
                                <tr>
                                    <th>要介護1</th>
                                    <th>要介護2</th>
                                    <th>要介護3</th>
                                    <th>要介護4</th>
                                    <th>要介護5</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>16,692円</td>
                                    <td>19,616円</td>
                                    <td>26,931円</td>
                                    <td>30,806円</td>
                                    <td>36,065円</td>
                                </tr>
                            </tbody>
                        </table>
                        
                        
                        
                        
                        
                        
                        .table-price {
  border-collapse: separate;
  border-spacing: 4px;

  > thead {
    @media (max-width: $screen-sm-max) {
      float: left;
      width: 50%;
    }

    > tr {
      &,
      > th {
        @media (max-width: $screen-sm-max) {
          display: block;
        }
      }

      > th {
        font-size: 24px;
        text-align: center;
        border-bottom: 0;

        @media (max-width: $screen-sm-max) {
          padding-top: 12px !important;
          padding-bottom: 8px !important;
          font-size: 20px;
          border-bottom: 5px solid #fff;
        }
      }
    }
  }

  > thead,
  > tbody {
    > tr {
      > th {
        padding: 9px 10px 5px;
        color: #42210b;
        vertical-align: middle;
        background-color: #ffc099;

        small {
          font-size: 14px;

          @media (max-width: $screen-sm-max) {
            font-size: 12px;
          }
        }
      }
    }
  }

  > tbody {
    > tr {
      > th,
      > td {
        padding: 9px 10px 5px;
        border-top: 0;
      }

      > th {
        font-size: 20px;
        font-weight: bold;

        @media (min-width: $screen-sm-min) {
          width: 200px;
          padding-left: 48px;
        }

        @media (max-width: $screen-sm-max) {
          font-size: 16px;
        }
      }

      > td {
        background-color: #ffe1c2;

        @media (min-width: $screen-sm-min) {
          padding-right: 40px;
          padding-left: 45px;
        }

        @media (max-width: $screen-sm-max) {
          padding-right: 5px;
          padding-left: 5px;
        }

        small {
          font-size: 14px;

          @media (max-width: $screen-sm-max) {
            font-size: 12px;
          }
        }
      }
    }
  }

  dl {
    color: #42210b;

    dt {
      font-size: 22px;
      font-weight: bold;
      white-space: nowrap;

      @media (max-width: $screen-sm-max) {
        padding-right: 0;
        font-size: 16px;
      }
    }

    dd {
      vertical-align: middle;

      @media (min-width: $screen-sm-min) {
        text-align: right;
      }
    }
  }

  &.table-horizontal {
    margin-bottom: 14px;
    border-spacing: 6px 5px;

    > tbody {
      @media (max-width: $screen-sm-max) {
        display: block;
        float: left;
        width: 50%;
      }

      > tr {
        &,
        > td {
          @media (max-width: $screen-sm-max) {
            display: block;
          }
        }

        > td {
          padding: 11px 10px 9px;
          font-size: 24px;
          text-align: center;

          @media (max-width: $screen-sm-max) {
            font-size: 20px;
            border-bottom: 5px solid #fff;
            border-left: 6px solid #fff;
          }
        }
      }
    }
  }
}