Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <!-- inspired by https://dev.to/winduptoy/a-javascript-free-frontend-2d3e -->
<div id="myToggledUI">
  Contents</div>
<input type="checkbox" id="mobile-check">
<label id="mobile-button" for="mobile-check"></label>
<div id="nav-pop">
  <div id="nav-pop-close"></div>
  <details open>
    <summary><strong>summary element</strong></summary>
    <ol>
      <li>
        <details>
          <summary><strong>I'm another summary element</strong></summary>
          <p>I'm the details</p>
          </detials>
      </li>
      <li>Current invoice: $75.30</li>
      <li>Due date: 5/6/19</li>
    </ol>
    </details>
    <form>
      <table>
        <tr>
          <td>
            <label for='name'>Name:</label>
          </td>
          <td>
            <input id='name' placeholder="minlength='3' maxlength='8'" minlength='3' maxlength='8' required></input>
          </td>
        </tr>
        <tr>
          <td>
            <label for='position'>Number:</label>
          </td>
          <td>
            <input id='position' placeholder='step="10" min="0" max="10"' type='number' step="10" min="0" max="10"></input>
          </td>
        </tr>
        <tr>
          <td>
            <label for='phone'>Text:</label>
          </td>
          <td style='position:relative;'>
            <select style="position:absolute;top:0px;left:0px;" onchange="document.getElementById('displayValue').value=this.options[this.selectedIndex].text; document.getElementById('idValue').value=this.options[this.selectedIndex].value;">
    <option></option>
    <option value="one">one</option>
    <option value="two">two</option>
    <option value="three">three</option>
  </select>
            <input type="text" name="displayValue" id="displayValue" placeholder="add/select a value" onclick="this.select()" style="position:absolute;top:0px;left:0px;border:1px solid #556; margin:0;">
            <input name="idValue" id="idValue" type="hidden">
          </td>
        </tr>
        <tr>
          <td>
            <label for='cell'>Cell phone:</label>
          </td>
          <td>
            <input id='cell' placeholder="(888) 333-3333"></input>
          </td>
        </tr>
        <tr>
          <td>
            <label for='fax'>Fax:</label>
          </td>
          <td>
            <input id='fax' placeholder='(888) 666-6666'></input>
          </td>
        </tr>
        <tr>
          <td>
            <label for='email'>Email:</label>
          </td>
          <td>
            <input id='email' placeholder='pattern="\d+@qq.com"' type='email' pattern="\d+@qq.com" required></input>
          </td>
        </tr>
        <tr>
          <td colspan=2 style='text-align: center;'>
            <input type='submit'>
          </td>

        </tr>
      </table>
    </form>
</div>
              
            
!

CSS

              
                html,
body {
  width: 100%;
  height: 100%;
}
input {
  width: 170px;
  height: 20px;
  margin: 10px 0;
}
select {
  width: 190px;
  height: 25px;
}
input:valid {
  background-color: powderblue;
}
input:invalid {
  background-color: pink;
}
#mobile-button {
  opacity: 0;
  background-image: url("https://optimumwebdesigns.com/icons/menu.png");
  background-color: rgba(0, 0, 0, 0.7);
  background-size: 30px 30px;
  float: right;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-position: 90% 4%;
  top: 0;
  position: fixed;
  background-color: #e6e6e6;
  cursor: pointer;
  display: block;
  transition: ease 1s;
}
#nav-pop {
  background: hsla(291, 64%, 42%, 0.47);
  height: 100vh;
  padding: 10px;
  color: hsl(0, 77%, 3%);
}
#mobile-check ~ #nav-pop {
  opacity: 0.5;
  position: fixed;
  width: 70%;
  height: 100vh;
  right: -100%;
  margin-top: 0;
  margin-right: 0;
  z-index: 999999;
  transition: ease 0.6s;
  -webkit-transition: ease 0.6s;
  transform: translateX(0);
  -webkit-transform: translateX(0);
}
#mobile-check:checked ~ #nav-pop {
  opacity: 1;
  right: 100%;
  transform: translateX(100%);
  -webkit-transform: translateX(100%);
}
#mobile-check:checked ~ #mobile-button {
  opacity: 0.5;
}

              
            
!

JS

              
                var dragged;
Array.from(document.querySelectorAll("tr")).map(item =>
  item.setAttribute("draggable", "true")
);
/* events fired on the draggable target 
*/
document.addEventListener("drag", function(event) {}, false);

document.addEventListener(
  "dragstart",
  function(event) {
    // store a ref. on the dragged elem
    dragged = event.target;
    // make it half transparent
    event.target.style.opacity = 0.5;
  },
  false
);
/* events fired on the drop targets. In order to have the drop event occur on an element, you must cancel the ondragover events */
document.addEventListener(
  "dragover",
  function(event) {
    // prevent default to allow drop
    event.preventDefault();
  },
  false
);
document.addEventListener(
  "drop",
  function(event) {
    console.log(event);
    // prevent default action (open as link for some elements)
    event.preventDefault();
    // move dragged elem to the selected drop target
    // if (event.target.className == "dropzone") {
    event.target.style.background = "";
    document.querySelectorAll("tbody")[0].removeChild(dragged);
    event.target.closest("tr").after(dragged);
    // }
  },
  false
);

              
            
!
999px

Console