123

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="editor">
  <div class="toolbar">
    <div class="line">
      
      <div class="box">
        <span class="btn icon smaller" data-action="bold" title="Bold">
          <img src="https://image.flaticon.com/icons/svg/25/25432.svg">
        </span>
        <span class="btn icon smaller" data-action="italic" title="Italic">
          <img src="https://image.flaticon.com/icons/svg/25/25392.svg">
        </span>
        <span class="btn icon smaller" data-action="underline" title="Underline">
          <img src="https://image.flaticon.com/icons/svg/25/25433.svg">
        </span>
        <span class="btn icon smaller" data-action="strikeThrough" title="Strike through">
          <img src="https://image.flaticon.com/icons/svg/25/25626.svg">
        </span>
      </div>
      
      <div class="box">
        <span class="btn icon has-submenu">
          <img src="https://image.flaticon.com/icons/svg/25/25351.svg">
          <div class="submenu">
            <span class="btn icon" data-action="justifyLeft" title="Justify left">
              <img src="https://image.flaticon.com/icons/svg/25/25351.svg">  
            </span>
            <span class="btn icon" data-action="justifyCenter" title="Justify center">
              <img src="https://image.flaticon.com/icons/svg/25/25440.svg">  
            </span>
            <span class="btn icon" data-action="justifyRight" title="Justify right">
              <img src="https://image.flaticon.com/icons/svg/25/25288.svg">  
            </span>
            <span class="btn icon" data-action="formatBlock" title="Justify block">
              <img src="https://image.flaticon.com/icons/svg/25/25181.svg">  
            </span>
          </div>
        </span>
        <span class="btn icon" data-action="insertOrderedList" title="Insert ordered list">
          <img src="https://image.flaticon.com/icons/svg/25/25242.svg">  
        </span>
        <span class="btn icon" data-action="insertUnorderedList" title="Insert unordered list">
          <img src="https://image.flaticon.com/icons/svg/25/25648.svg">  
        </span>
        <span class="btn icon" data-action="outdent" title="Outdent">
          <img src="https://image.flaticon.com/icons/svg/25/25410.svg">  
        </span>
        <span class="btn icon" data-action="indent" title="Indent">
          <img src="https://image.flaticon.com/icons/svg/25/25233.svg">  
        </span>
        
      </div>
      <div class="box">
        <span class="btn icon" data-action="insertHorizontalRule" title="Insert horizontal rule">
          <img src="https://image.flaticon.com/icons/svg/25/25232.svg">  
        </span>
      </div>
      
    </div>
    <div class="line">
      
      <div class="box">
        <span class="btn icon smaller" data-action="undo" title="Undo">
          <img src="https://image.flaticon.com/icons/svg/25/25249.svg">
        </span>
        <span class="btn icon" data-action="removeFormat" title="Remove format">
          <img src="https://image.flaticon.com/icons/svg/25/25454.svg">  
        </span>
      </div>
      
      <div class="box">
        <span class="btn icon" data-action="code" title="Show HTML-Code">
          <img src="https://image.flaticon.com/icons/svg/25/25185.svg">
        </span>
      </div>
      
    </div>
  </div>
  <div class="content-area">
    <div class="visuell-view" contenteditable>
      <p style="text-align: center;">Welcome to my <b>WYSIWYG</b> Editor <i>(What you see is what you get)</i>!</p>
      <p style="text-align: center;">It's only made of <u>HTML5</u>, <i><u>CSS3</u> </i>and pure <u>JavaScript</u>, <strike>no framework</strike>!</p>
      <hr>
      <p style="text-align: center;"><b>See for yourself! 😃❤️</b></p>
    </div>
    <textarea class="html-view"></textarea>
  </div>
</div>
<footer>
  <p>coded by <a href="https://webdeasy.de/?referer=cp-YoVmBx" target="_blank">WebDEasy</a></p>
  <p>Icons made by <a href="https://www.flaticon.com/authors/dave-gandy" title="Dave Gandy">Dave Gandy</a> from <a href="https://www.flaticon.com/"                 title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/"                 title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></p>
</footer>
            
          
!
            
              body {
  margin: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Helvetica Neue', 'Helvetica', arial, sans-serif;
}

.editor {
  width: 40rem;
  min-height: 18rem;
  box-shadow: 0 0 4px 1px rgba(0, 0, 0, 0.3);
  border-top: 6px solid #4a4a4a;
  border-radius: 3px;
  margin: 2rem;
  
  .toolbar {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    
    .line {
      display: flex;
      border-bottom: 1px solid #e2e2e2;
      
      &:last-child {
        border-bottom: none;
      }
      
      .box {
        display: flex;
        border-left: 1px solid #e2e2e2; 
        
        .btn {
          display: block;
          display: flex;
          align-items: center;
          justify-content: center;
          position: relative;
          transition: .2s ease all;

          &:hover, &.active {
            background-color: #e1e1e1;
            cursor: pointer;
          }
          
          &.icon img {
            width: 15px;
            padding: 10px;
          }
          
          &.icon.smaller img {
            width: 12px;
          }
          
          &.has-submenu {
            width: 20px;
            padding: 0 10px;
            
            &::after {
              content: '';
              width: 6px;
              height: 6px;
              position: absolute;
              background-image: url(https://image.flaticon.com/icons/svg/25/25243.svg);
              background-repeat: no-repeat;
              background-size: cover;
              background-position: center;
              right: 4px;
            }
            
            .submenu {
              display: none;
              position: absolute;
              top: 36px;
              left: -1px;
              background-color: #FFF;
              border: 1px solid #b5b5b5;
              border-top: none;
              
              .btn {
                width: 39px;
              }
            }
            
            &:hover .submenu {
              display: block;
            }
          }
        }  
      }
    }
  }
  
  .content-area {
    padding: 15px 12px;
    line-height: 1.5;
    
    .visuell-view {
      outline: none;
      
      p {
        margin: 12px 0;
      } 
    }
    
    .html-view {
      outline: none;
      display: none;
      width: 100%;
      height: 200px;
      border: none;
      resize: none;
    }
  }
}

footer {
  position: fixed;
  bottom: 0;
  display: flex;
  
  p {
    margin: 0.5rem 1rem;
    font-size: 12px;
  }
  
  a {
    text-decoration: none;
    font-weight: bold;
    color: #000;
  }
}
            
          
!
            
              const editor = document.getElementsByClassName('editor')[0];
const toolbar = editor.getElementsByClassName('toolbar')[0];
const buttons = toolbar.querySelectorAll('.btn:not(.has-submenu)');

for(let i = 0; i < buttons.length; i++) {
  let button = buttons[i];
  
  button.addEventListener('click', function(e) {
    let action = this.dataset.action;
    
    // custom action
    if(action === 'code') {
      const contentArea = editor.getElementsByClassName('content-area')[0];
      const visuellView = contentArea.getElementsByClassName('visuell-view')[0];
      const htmlView = contentArea.getElementsByClassName('html-view')[0];
      
      if(this.classList.contains('active')) { // show visuell view
        visuellView.innerHTML = htmlView.value;
        htmlView.style.display = 'none';
        visuellView.style.display = 'block';

        this.classList.remove('active');     
      } else {  // show html view
        htmlView.innerText = visuellView.innerHTML;
        visuellView.style.display = 'none';
        htmlView.style.display = 'block';

        this.classList.add('active'); 
      }
      
      return false;
    }
    
    document.execCommand(action, false);
  });
}
            
          
!
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.

Console