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 id="container">
  <div id="n1" class="appearing"></div>
  <div id="n2" class="disappearing">
   <div id="text">
     <div id="text-box">
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris cursus vestibulum neque, et scelerisque sem venenatis ac. Duis feugiat orci non consequat pulvinar. Sed felis neque, egestas at elit at, pretium mollis massa. Mauris id nunc id leo convallis auctor a nec urna. Nulla nec risus non sem laoreet sollicitudin faucibus ut augue. Aliquam consequat mattis interdum. Pellentesque eget tincidunt risus. Vivamus vel aliquet nisi, at venenatis tellus. Quisque felis orci, suscipit ac suscipit a, eleifend ac orci. Aenean tempus, dolor nec ultricies tincidunt, ex quam porta lorem, ac suscipit diam augue a urna. Donec ac enim non tortor hendrerit efficitur.
     </div>
   </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  overflow: hidden;
}
#container {
  font-family: Quicksand;
  font-weight: 500;
  font-size: 18px;
  color: white;
  margin-top: 70px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);

   height: 20em;
   width: 30em;
  display: flex;
  
}

#n1 {
  height: 20em;
  background-color: #7392c4;
  transition: width 1s;
} 

#n2 {
  height: 20em;
  background-color: #e06d99;
  transition: width 1s;
}

#text {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 20em;
  width: 30em;
  transition: opacity 1s;
}

#text-box {
  height: 18em;
  width: 28em;
  
}

.appearing {
  width: 100%;
}

.disappearing {
  width: 0%;
}
.disappearing #text {
  opacity: 0;
}

body {
  display: flex;
  alignt-items: center;
  justify-content: center;
}
              
            
!

JS

              
                var container = document.getElementById("container");

let n1 = document.getElementById("n1");
let n2 = document.getElementById("n2");

n1Classes = n1.classList
n2Classes = n2.classList

container.addEventListener("click", (e) => {
  container.getBoundingClientRect()
  
  var x = e.pageX - container.getBoundingClientRect().x
  
  var y = e.pageY - container.getBoundingClientRect().y
  console.log(x,y)
  if(n1.classList.contains("appearing")) {
    n1.classList.remove("appearing")
    n1.classList.add("disappearing")
    n2.classList.remove("disappearing");
    n2.classList.add("appearing")
  }
  else if(n2.classList.contains("appearing")) {
    n2.classList.remove("appearing")
    n2.classList.add("disappearing")
    n1.classList.remove("disappearing")
    n1.classList.add("appearing")
  }
})

 
              
            
!
999px

Console