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

              
                    <table class="desktop">
      <thead>
      <tr>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Job Title</th>
      </tr>
      </thead>
      <tbody>
      <tr>
        <td>James</td>
        <td>Matman</td>
        <td>Chief Sandwich Eater</td>
      </tr>
      <tr>
        <td>The</td>
        <td>Tick</td>
        <td>Crimefighter Sorta</td>
      </tr>
      </tbody>
    </table>

    <table class="desktop">
      <thead>
      <tr>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Job Title</th>
        <th>Favorite Color</th>
        <th>Wars or Trek?</th>
        <th>Porn Name</th>
        <th>Date of Birth</th>
        <th>Dream Vacation City</th>
        <th>GPA</th>
        <th>Arbitrary Data</th>
      </tr>
      </thead>
      <tbody>
      <tr>
        <td>James</td>
        <td>Matman</td>
        <td>Chief Sandwich Eater</td>
        <td>Lettuce Green</td>
        <td>Trek</td>
        <td>Digby Green</td>
        <td>January 13, 1979</td>
        <td>Gotham City</td>
        <td>3.1</td>
        <td>RBX-12</td>
      </tr>
      <tr>
        <td>The</td>
        <td>Tick</td>
        <td>Crimefighter Sorta</td>
        <td>Blue</td>
        <td>Wars</td>
        <td>John Smith</td>
        <td>July 19, 1968</td>
        <td>Athens</td>
        <td>N/A</td>
        <td>Edlund, Ben (July 1996).</td>
      </tr>
      <tr>
        <td>Jokey</td>
        <td>Smurf</td>
        <td>Giving Exploding Presents</td>
        <td>Smurflow</td>
        <td>Smurf</td>
        <td>Smurflane Smurfmutt</td>
        <td>Smurfuary Smurfteenth, 1945</td>
        <td>New Smurf City</td>
        <td>4.Smurf</td>
        <td>One</td>
      </tr>
      <tr>
        <td>Cindy</td>
        <td>Beyler</td>
        <td>Sales Representative</td>
        <td>Red</td>
        <td>Wars</td>
        <td>Lori Quivey</td>
        <td>July 5, 1956</td>
        <td>Paris</td>
        <td>3.4</td>
        <td>3451</td>
      </tr>
      <tr>
        <td>Captain</td>
        <td>Cool</td>
        <td>Tree Crusher</td>
        <td>Blue</td>
        <td>Wars</td>
        <td>Steve 42nd</td>
        <td>December 13, 1982</td>
        <td>Las Vegas</td>
        <td>1.9</td>
        <td>Under the couch</td>
      </tr>
      </tbody>
    </table>
              
            
!

CSS

              
                @import "compass/css3";

table {
  margin: 50px; 
  td, th {
    padding: 10px;
    text-align: left;
  }
}

.desktop {
  tbody tr:nth-child(odd) {
    background: #eee;
  }
}

.generated_for_mobile tr.odd {
  background: #eee;
}
              
            
!

JS

              
                $('table').each(function() {
  var table = $(this); // cache table object
  var head = table.find('thead th');
  var rows = table.find('tbody tr').clone(); // appending afterwards does not break original table

  // create new table
  var newtable = $(
    '<table class="generated_for_mobile">' +
    '  <tbody>' +
    '  </tbody>' +
    '</table>'
  );

  // cache tbody where we'll be adding data
  var newtable_tbody = newtable.find('tbody');

  rows.each(function(i) {
    var cols = $(this).find('td');
    var classname = i % 2 ? 'even' : 'odd';
    cols.each(function(k) {
      var new_tr = $('<tr class="' + classname + '"></tr>').appendTo(newtable_tbody);
      new_tr.append(head.clone().get(k));
      new_tr.append($(this));
    });
  });

  $(this).after(newtable);
});
              
            
!
999px

Console