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 class='phone'>
  <div class='inside'>
    <div id='title-page' class=''>
      <h1>A Story</h1>
      <h3>as told by a few letters</h3>
      <div class='next' style='display:block;'><a href='#ch1'>&#x2193;</a></div> 
    </div>
    
    <div id='ch1' class='page'>
      <div class='ch1-block'>
        <p>There once was a little 'a'.<br><br> Alone they sat dreaming of one day becoming a big 'a'.</p>
       <div class='ch1-game'>
         <h1 onclick='changeFont(this)'>a</h1>
        </div> 
      </div>
      <div class='next'><a href='#ch2' onclick='ch2Open()'>&#x2193;</a></div>
    </div>
    
     <div id='ch2' class='page'>
      <div class='ch1-block'>
       <div class='ch2-game'>
         <h1 onclick='ch2(this)'>a</h1>
         <h1 class='b'>b</h1>
         <p>Because I can. Now leave me little 'b'.</p>
        </div> 
      </div>
      <div class='next'><a href='#ch3' onclick='ch3Open()'>&#x2193;</a></div>
    </div>
  
  <div id='ch3' class='page'>
      <div class='ch1-block'>     
       <div class='ch3-game'>
         <h1 onclick='ch3(this)'>a</h1>
         <h1 class='c'>c</h1>
         <p>I guess I am a big 'A'.</p>
        </div> 
      </div>
      <div class='next'><a href='#title-page' onclick='theEnd()'>&#x2193;</a></div>
    </div>
  </div>
</div>

<link href="https://fonts.googleapis.com/css?family=Montserrat:300,500,700,900&display=swap" rel="stylesheet">
              
            
!

CSS

              
                ::-webkit-scrollbar {
  width:5px;
}
:root {
  --fontFamily:'Montserrat', sans-serif;
  --hide:none;
  --aAnimation:ch1 2s linear infinite;
  --bAnimation:none;
  --bBubble:"Why do you daydream little 'a'?";
  --cAnimation:none;
  --cBubble:"Whatcha doing little 'a'?"
  
}

html {
  font-family: 'Montserrat', sans-serif;
  scroll-behavior: smooth;
  background:linear-gradient(to bottom right, transparent 18px, #efefef 18px, transparent 20px);
  background-size:20px 20px;
}

.phone {
  width:330px;
  height:668px;
  border-radius:20px;
  box-shadow:0 0 0 2px lightgray;
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
  background:white;
}
.inside {
  width:320px;
  height:568px;
  box-shadow:0 0 0 2px lightgray;
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
  overflow:hidden;
  scroll-behavior: smooth;
  background:white;
}

#title-page {
  width:100%;
  min-height:568px;
}

#title-page h1 {
  font-size:85px;
  line-height:100%;
  font-weight:900;
  padding:0 20px;
  text-align:left;
}
#title-page h3 {
  padding:0 20px;
}

.next {
  position: absolute;
  bottom: 10px;
  right: 5px;
  font-size: 36px;
  line-height: 100%;
  user-select:none;
  display:none;
  animation:downArrow 2s linear infinite;
}
@keyframes downArrow {
  50% { bottom:0px; }
}
.next a{  
  color:black;
  text-decoration:none;
}

#title-page .next {
  right:50%;
  transform:translateX(50%);
}
/* ch1 */
.page {
  margin-top:100px;
  position:relative;
}
.ch1-block {
  width:100%;
  height:568px;
  background:#efefef;
}

.page p {
  padding:20px;
  position:absolute;
  bottom:0;
}

.ch1-game {
  position:absolute;
  bottom:0;
  width:100%;
  height:50%;
}
.page h1 {
  font-size:100px;
  font-weight:300;
  text-align:center;
  margin-top:0;
  user-select:none;
  cursor:pointer;
  animation:var(--aAnimation);
}
@keyframes ch1 {
  50% { transform:scale(1.2) }
}
.ch1-game h1:before {
  content: '';
  position: absolute;
  top: -32%;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 120px;
  background: red;
  background: radial-gradient(circle, white 50%, transparent 50%);
  background-size: 30px 30px;
  display:var(--hide);
}
.ch1-game h1:after {
  content: 'A';
  position: absolute;
  top: -75%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 72px;
  width:115px;
  height:115px;
  line-height: 115px;
  font-weight: 700;
  font-family: var(--fontFamily);
  background: white;
  border-radius: 25px;
  display:var(--hide);
}

/* ch2 */
#ch2 .ch1-block {
  background:white;
}
#ch2 h1 {
  width:50%;
  position:absolute;
  top:50%;
  transition:1s;
}
#ch2 h1:nth-child(2) {
  right:-50%;
  transition:1s;
}
#ch2 h1:nth-child(2):after {
  content: var(--bBubble);
  position: absolute;
  top: -30%;
  left: -25%;
  display: block;
  font-size: 20px;
  text-align: left;
  opacity:0;
  animation:var(--bAnimation);
}
@keyframes b {
  100% { opacity:1; }
}

/* ch3 */
#ch3 h1:nth-child(1) {
  width:50%;
  position:absolute;
  top:50%;
  transform:scaleX(-1);
  transition:1s;
}
#ch3 h1:nth-child(2) {
  width:50%;
  position:absolute;
  right:-50%;
  top:50%;
  transition:1s;
}
#ch3 h1:nth-child(2):after {
  content: var(--cBubble);
  position: absolute;
  top: -10%;
  left: 0%;
  display: block;
  font-size: 20px;
  text-align: left;
  opacity: 0;
  animation: var(--cAnimation);
}
@keyframes c {
  100% { opacity:1; }
}

#ch3 p, #ch2 p {
  bottom:40%;
  opacity:0;
  transition:.75s;
  font-size:20px;
  font-weight:300;
  text-align:left;
  padding-left:20px;
  width:60%;
}
              
            
!

JS

              
                let root = document.documentElement
var fonts = ['monospace','serif','cursive','sans-serif']
var f = 0
function changeFont(e) {
  f++
  if(f < 3) {
  root.style.setProperty('--fontFamily',fonts[f])  
  } else {
    f = 0
    root.style.setProperty('--fontFamily',fonts[f])  
  }  
  root.style.setProperty('--hide','block')
  root.style.setProperty('--aAnimation','none') 
  document.querySelector('#ch1 .next').style.display = "block"
}

function ch2Open() {
  document.querySelector('.b').style.right = "0"
  root.style.setProperty('--bAnimation','b 1s linear .5s forwards') 
}
function ch2(e) {
  e.style.transform = 'scaleX(-1)'  
  document.querySelector('#ch2 p').style.opacity = "1"
  root.style.setProperty('--bBubble',"''")
  setTimeout(function(){
    document.querySelector('.b').style.right = "-100%"
    document.querySelector('#ch2 .next').style.display = "block"
  },3500)  
}

function ch3Open() {
  document.querySelector('.c').style.right = "0"
  root.style.setProperty('--cAnimation','c 1s linear .5s forwards') 
}
function ch3(e) { 
  document.querySelector('#ch3 p').style.opacity = "1"
  document.querySelector('#ch3 p').innerHTML = '#$%@^!'
  root.style.setProperty('--cBubble',"''")
  setTimeout(function(){
    document.querySelector('.c').style.right = "-100%"
    document.querySelector('#ch3 p').innerHTML = "I guess I am already a big 'A'."
    document.querySelector('#ch3 .next').style.display = "block"
  },1500)    
}

function theEnd() {
  document.querySelector('#title-page').style.paddingTop = '50px'
  document.querySelector('#title-page h1').innerHTML = 'The End'
  document.querySelector('#title-page h3').innerHTML = "no letters were harmed in the making of this production<br><br>don't be like little 'a' y'all"
  document.querySelector('#title-page .next').style.display = 'none'
}
              
            
!
999px

Console