cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

            
              <h2>My Email Newsletters</h2>
<p>Email newsletters you create with the Email Newsletter Generator will be saved here. To create a new email newsletter, <a href="#">click here</a></p>
<table data-table>
  <thead>
    <tr>
      <th>Title</th>
      <th>Added</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr id="unique_id_1">
      <td>July 2015 Newsletter</td>
      <td>6/14/2015</td>
      <td>
        <a href="#" onclick="view('unique_id_1')" data-caption="View"><i class="ion-eye"></i></a>
        <a href="#" onclick="edit('unique_id_1')" data-caption="Edit"><i class="ion-edit"></i></a>
        <a href="#" onclick="duplicate('unique_id_1')" data-caption="Duplicate"><i class="ion-ios-copy"></i></a>
        <a href="#" data-delete data-caption="Delete"><i class="ion-close"></i></a>
      </td>
    </tr>
    <tr id="unique_id_2">
      <td>June 2015 Newsletter</td>
      <td>6/13/2015</td>
      <td>
        <a href="#" onclick="view('unique_id_2')" data-caption="View"><i class="ion-eye"></i></a>
        <a href="#" onclick="edit('unique_id_2')" data-caption="Edit"><i class="ion-edit"></i></a>
        <a href="#" onclick="duplicate('unique_id_2')" data-caption="Duplicate"><i class="ion-ios-copy"></i></a>
        <a href="#" data-delete data-caption="Delete"><i class="ion-close"></i></a>
      </td>
    </tr>
    <tr id="unique_id_3">
      <td>May 2015 Newsletter</td>
      <td>4/28/2015</td>
      <td>
        <a href="#" onclick="view('unique_id_3')" data-caption="View"><i class="ion-eye"></i></a>
        <a href="#" onclick="edit('unique_id_3')" data-caption="Edit"><i class="ion-edit"></i></a>
        <a href="#" onclick="duplicate('unique_id_3')" data-caption="Duplicate"><i class="ion-ios-copy"></i></a>
        <a href="#" data-delete data-caption="Delete"><i class="ion-close"></i></a>
      </td>
    </tr>
  </tbody>
</table>
            
          
!
            
              * {
  font-family:'Source Sans Pro', 'Open Sans', Roboto, 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Myriad Pro', 'Segoe UI', Myriad, Helvetica, 'Lucida Grande', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, Geneva, Arial, sans-serif;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
h2, p {
  margin: .5em 0;
}

/* Table Styles */
@element '[data-table]' {
  $this,
  $this *,
  $this *:before,
  $this *:after {
    -webkit-box-sizing: border-box !important;
    -moz-box-sizing: border-box !important;
    box-sizing: border-box !important;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-kerning: auto;
  }
  $this {
    width: 100%;
    margin: 15px 0 10px 0 !important;
    color: #333;
    background: white;
    border: 1px solid #999 !important;
    font-size: 12pt;
    border-collapse: collapse !important;
  }
  $this thead {
    display: table-header-group;
  }
  $this tfoot {
    display: table-footer-group;
  }
  $this thead th,
  $this tfoot th {
    color: #777;
    background: rgba(0,0,0,.1);
    border-bottom-color: #ccc !important;
  }
  $this caption {
    padding:.5em;
  }
  $this tbody tr:nth-of-type(odd) {
    background: rgba(0,0,0,.05);
  }
  $this td:last-child {
    width: 100%;
    text-align: center;
  }
  $this a {
    display: inline-block;
    width: 30px;
    height: 30px;
    color: #999;
    line-height: 27px !important;
    font-size: 20px !important;
    text-align: center;
    border: 2px solid currentColor;
    border-radius: 100%;
    position: relative;
    underline: none;
    transition: all .2s ease-in-out;
  }
  $this a:nth-of-type(2) {
     font-size: 18px !important;
  }
  $this a:hover {
    color: #773570;
  }
  $this a[data-delete]:hover {
    color: #c00;
  }
  $this a + a {
    margin-left: 10px;
  }
  $this a:before {
    content: '';
    border: 5px solid transparent;
    border-top-color: #773570;
    position: absolute;
    top: -7px;
    left: calc(50% - 5px);
  }
  $this a:after {
    content: attr(data-caption);
    display: block;
    width: auto;
    padding: 5px 8px;
    border-radius: 3px;
    position: absolute;
    top: -33px;
    right: -10px;
    font-size: 12pt;
    line-height: 12pt;
    font-weight: 500;
    color: white;
    text-align: center;
    background: #773570;
    box-shadow: inset rgba(0,0,0,.3) 0 0 1px, inset rgba(255,255,255,.3) 0 1px 0, rgba(0,0,0,.10) 0 1px 2px;
  }
  $this a:before,
  $this a:after {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: all .2s ease-in-out;
  }
  $this a:hover:before,
  $this a:hover:after {
    visibility: visible;
    opacity: 1;
  }
  $this a[data-delete]:before {
    border-top-color: #c00;
  }
  $this a[data-delete]:after {
    background: #c00;
  }
}
/* Stacked Table */
@element '[data-table]' and (max-width: 525px) {
  $this caption,
  $this tbody,
  $this tr,
  $this th,
  $this td { display: block; width: 100%; }
  $this thead,
  $this tfoot {
    display: none;
  }
  $this td:before {
    content: attr(data-header)' ';
  }
  $this td:first-child {
    font-weight: 700;
    color: #333;
    font-size: 14pt;
    line-height: 1.1;
    letter-spacing: -.02em;
    padding: 10px 5px 0 10px;
  }
  $this td:nth-child(2) {
    padding: 0 5px 0 10px;
    font-size: 10pt;
    color: #777;
    font-weight: 500;
  }
  $this td:first-child:before,
  $this td:last-child:before {
    content: '';
  }
  $this tr + tr {
    border-top: 1px solid #ccc;
  }
  $this td {
    border: none;
    color: #333;
    font-size: 12pt;
    font-weight: 400;
    text-align: center;
    padding-bottom: 10px;
  }
}
/* Wide Table */
@element '[data-table]' and (min-width: 525px) {
  $this { display: table; width: auto; }
  $this caption { display: table-caption; width: auto; }
  $this thead { display: table-header-group; width: auto; }
  $this tbody { display: table-row-group; width: auto; }
  $this tfoot { display: table-footer-group; width: auto; }
  $this tr { display: table-row; width: auto; }
  $this th,
  $this td { display: table-cell; width: auto; }
  $this td:before {
    display: none;
  }
  $this th,
  $this td {
    padding: 10px !important;
    text-align: left;
    border: 1px solid lightgrey;
  }
  $this th:nth-child(2) {
    border-right: none !important;
  }
  $this th:last-child {
    border-left: none !important;
    background-image: none !important;
  }
  $this td {
    color: #333;
    font-size: 12pt;
    font-weight: 400;
  }
  $this a {
    display: block;
    float: left;
  }
  $this td:first-child {
    font-weight: 600;
    width: 100%;
  }
  $this td:last-child:after {
    content: '';
    display: block;
    clear: both;
  }
  $this td:last-child {
    padding: 7px !important;
    min-width: calc(30px + 10px + 30px + 10px + 30px + 10px + 30px + 15px);
  }
}
            
          
!
            
              // Responsive Tables
var tables = document.getElementsByTagName('table');
for (i=0;i<tables.length;i++){
  var headers = tables[i].getElementsByTagName('th'),
      rows = tables[i].getElementsByTagName('tr'),
      header = [];
  if (tables[i].getAttribute('data-table') == undefined) {
    tables[i].setAttribute('data-table',i)
  }
  if (tables[i].getAttribute('data-table-theme') == undefined) {
    tables[i].setAttribute('data-table-theme','default')
  }
  for (h=0;h<headers.length;h++){
    header.push(headers[h].innerHTML);
  }
  for (r=0;r<rows.length;r++){
    var cells = rows[r].getElementsByTagName('td');
    for (c=0;c<cells.length;c++){
      if (cells[c].getAttribute('data-header') == undefined && header[c] !== undefined) {
        cells[c].setAttribute('data-header',header[c]);
      }
    }
  }
}

// Table Button Demo Functionality
scanButtons();
function scanButtons() {
  var buttons = document.querySelectorAll('[data-delete]');
  for (i=0;i<buttons.length;i++){
    buttons[i].addEventListener('click',remove);
  }
}
function view(id){
  var link = document.createElement('a'),
      timestamp = Date.now();
  link.id = timestamp;
  link.href = 'http://example.com/' + id; // Link to view newsletter
  link.setAttribute('target','_blank');
  link.style.cssText = 'position:absolute;right:-10%;bottom:-10%;';
  document.body.appendChild(link);
  document.getElementById(timestamp).dispatchEvent(new MouseEvent('click'));
  document.getElementById(timestamp).parentElement.removeChild(document.getElementById(timestamp));
}
function edit(id){
  var link = document.createElement('a'),
      timestamp = Date.now();
  link.id = timestamp;
  link.href = 'http://example.com/' + id + '?edit'; // Link to edit newsletter
  link.setAttribute('target','_blank');
  link.style.cssText = 'position:absolute;right:-10%;bottom:-10%;';
  document.body.appendChild(link);
  document.getElementById(timestamp).dispatchEvent(new MouseEvent('click'));
  document.getElementById(timestamp).parentElement.removeChild(document.getElementById(timestamp));
}
function duplicate(id){
  var clone = document.getElementById(id).cloneNode(true),
      timestamp = Date.now();
  clone.id+='_'+timestamp;
  document.getElementById(id).parentNode.appendChild(clone);
  // Also clone the newsletter on the backend somewhere around here
  clone.querySelectorAll('[data-delete]')[0].addEventListener('click',remove);
  var orig = clone.style.background;
  clone.style.background = 'lightyellow';
  clone.style.transition = 'background 2s ease-in-out';
  setTimeout(function(){clone.style.background=orig},1000)
  setTimeout(function(){clone.style.transition=''},4000)
}
function remove(){
  // Remove the newsletter from the backend somewhere around here
  this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console