Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="table-wrapper">
  <table>
    <thead>
      <tr>
        <th>ID</th>
        <th class="fixed-column">Name</th>
        <th>Email</th>
        <th>Phone</th>
        <th>Address</th>
        <th>City</th>
        <th>Age</th>
        <th>Occupation</th>
        <th>Company</th>
        <th>Salary</th>
        <th>Department</th>
        <th>Join Date</th>
        <th>Notes</th>
      </tr>
    </thead>
    <tbody>
      <tr class="active">
        <td name="S/N">1</td>
        <td name="Name" class="fixed-column">John Doe</td>
        <td name="Email">johndoe@example.com</td>
        <td name="Phone" class="accordion-content">123-456-7890</td>
        <td name="Address" class="accordion-content">123 Main St</td>
        <td name="City" class="accordion-content">New York</td>
        <td name="Age" class="accordion-content">35</td>
        <td name="Occupation">Software Engineer</td>
        <td name="Company" class="accordion-content">ABC Corporation</td>
        <td name="Salary" class="accordion-content">$80,000</td>
        <td name="Department" class="accordion-content">Engineering</td>
        <td name="Join Date" class="accordion-content">2022-01-01</td>
        <td name="Notes" class="accordion-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>
      </tr>
      <tr>
        <td name="S/N">2</td>
        <td name="Name" class="fixed-column">Jane Smith</td>
        <td name="Email">janesmith@example.com</td>
        <td name="Phone" class="accordion-content">987-654-3210</td>
        <td name="Address" class="accordion-content">456 Park Ave</td>
        <td name="City" class="accordion-content">Los Angeles</td>
        <td name="Age" class="accordion-content">42</td>
        <td name="Occupation">Marketing Manager</td>
        <td name="Company" class="accordion-content">XYZ Company</td>
        <td name="Salary" class="accordion-content">$95,000</td>
        <td name="Department" class="accordion-content">Marketing</td>
        <td name="Join Date" class="accordion-content">2021-05-15</td>
        <td name="Notes" class="accordion-content">Nulla luctus urna non sem condimentum commodo.</td>
      </tr>
      <tr>
        <td name="S/N">3</td>
        <td name="Name" class="fixed-column">Mark Johnson</td>
        <td name="Email">markjohnson@example.com</td>
        <td name="Phone" class="accordion-content">555-123-4567</td>
        <td name="Address" class="accordion-content">789 Elm St</td>
        <td name="City" class="accordion-content">Chicago</td>
        <td name="Age" class="accordion-content">28</td>
        <td name="Occupation">Graphic Designer</td>
        <td name="Company" class="accordion-content">Design Co.</td>
        <td name="Salary" class="accordion-content">$60,000</td>
        <td name="Department" class="accordion-content">Design</td>
        <td name="Join Date" class="accordion-content">2022-03-10</td>
        <td name="Notes" class="accordion-content">Proin aliquam arcu ut odio tincidunt elementum.</td>
      </tr>
      <tr>
        <td name="S/N">4</td>
        <td name="Name" class="fixed-column">Sarah Davis</td>
        <td name="Email">sarahdavis@example.com</td>
        <td name="Phone" class="accordion-content">111-222-3333</td>
        <td name="Address" class="accordion-content">321 Oak St</td>
        <td name="City" class="accordion-content">Miami</td>
        <td name="Age" class="accordion-content">37</td>
        <td name="Occupation">Accountant</td>
        <td name="Company" class="accordion-content">Finance Corp.</td>
        <td name="Salary" class="accordion-content">$75,000</td>
        <td name="Department" class="accordion-content">Finance</td>
        <td name="Join Date" class="accordion-content">2021-07-20</td>
        <td name="Notes" class="accordion-content">Aenean tincidunt magna sed est gravida facilisis.</td>
      </tr>
      <tr>
        <td name="S/N">5</td>
        <td name="Name" class="fixed-column">Michael Brown</td>
        <td name="Email">michaelbrown@example.com</td>
        <td name="Phone" class="accordion-content">444-555-6666</td>
        <td name="Address" class="accordion-content">555 Pine St</td>
        <td name="City" class="accordion-content">Seattle</td>
        <td name="Age" class="accordion-content">31</td>
        <td name="Occupation">Product Manager</td>
        <td name="Company" class="accordion-content">Tech Solutions</td>
        <td name="Salary" class="accordion-content">$90,000</td>
        <td name="Department" class="accordion-content">Product</td>
        <td name="Join Date" class="accordion-content">2021-09-05</td>
        <td name="Notes" class="accordion-content">Vestibulum sit amet purus mollis, feugiat ligula a, dictummi.</td>
      </tr>
    </tbody>
  </table>
</div>
              
            
!

CSS

              
                *,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  padding: 20px;
}
.table-wrapper {
  width: 100%;
  overflow-x: auto;
}
table {
  border-collapse: collapse;
}
th,
td {
  padding: 8px;
  text-align: left;
  border: 1px solid #ddd;
  white-space: nowrap;
}
th {
  background-color: #4caf50;
  color: white;
}

@media screen and (max-width: 768px) {
  table {
    width: 300px;
  }
  thead {
    display: none;
  }
  tr {
    display: block;
    margin-bottom: 20px;
    border-radius: 5px;
    border: 1px solid #ddd;
    cursor: pointer;
  }
  tr td {
    display: block;
    width: 100%;
    position: relative;
    white-space: pre-wrap;
    padding-top: 30px;
    border: none;
    border-bottom: 1px solid #ddd;
  }
  tr td:first-child {
    display: none;
  }
  tr td:nth-child(2) {
    background-color: #4caf50;
    color: white;
    padding: 8px;
    border-radius: 5px 5px 0 0;
  }
  tr td:not(:nth-child(2))::before {
    content: attr(name);
    position: absolute;
    top: 8px;
    left: 0;
    font-weight: bold;
    text-align: left;
    width: 100%;
    padding: 0 8px;
  } /* Add CSS for the hidden content */
  tr .accordion-content {
    display: none;
  }
  tr.active .accordion-content {
    display: block;
  }
}

              
            
!

JS

              
                document.addEventListener("DOMContentLoaded", function () {
  var accordionRows = document.querySelectorAll("tr");

  accordionRows.forEach(function (row) {
    row.addEventListener("click", function () {
      this.classList.toggle("active");
    });
  });
});

              
            
!
999px

Console