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="mobile-wrapper">
  <div class="mobile">
    <div class="photo"></div>
    <div class="screen">
      <div id="os-header" class="os-header">
        <div class="notch-left">
          <i class="fad fa-signal-4"></i>
          <i class="fad fa-flask-potion"></i>
        </div>

        <div class="notch-right">
          <i class="far fa-battery-half"></i>
          <span id="time" class="hour"></span>
        </div>
      </div>
      <div id="header" class="header">
        <div class="navbar">
          <button type="button" id="nav-toggle" class="nav-toggle">
            <span></span>
            <span></span>
            <span></span>
          </button>

          <div class="logo">
            Logo
          </div>

          <button class="user" type="button">
            <img src="https://randomuser.me/api/portraits/women/21.jpg"/>
          </button>
      </div>
    </div>
      
      <div id="aside" class="aside">
          <ul>
            <li><i class="fad fa-jack-o-lantern"></i>Spooky Link</li>
            <li><i class="fad fa-alicorn"></i> Magical Link</li>
            <li><i class="fad fa-rocket"></i> Space Link</li>
            <li><i class="fad fa-user-headset"></i> Need some Help ?</li>
        </ul>
      </div>

    <div id="content" class="content">
      <span class="block-title"></span>
      <span class="block-text"></span>
     
      <span class="block-text semi"></span>
      <span class="block-text semi"></span>
      <span class="block-text"></span>
      
      <span class="block-title"></span>
      <span class="block-text"></span>
      <span class="block-text"></span>
      
      <span class="block-title"></span>
      <span class="block-text"></span>
     
      <span class="block-text semi"></span>
      <span class="block-text semi"></span>
      <span class="block-text"></span>
      
      <span class="block-title"></span>
      <span class="block-text"></span>
      <span class="block-text"></span>
      
      
    </div>

    <div class="footer">
      <ul>
        <li>
          <button class="active" type="button"><i class="far fa-home-lg-alt"></i>Home</button>
        </li>
        <li>
          <button type="button"><i class="far fa-search"></i>Search</button>
        </li>
        <li>
          <button class="notification" data-notification="15" type="button"><i class="far fa-bell"></i>Notification</button>
        </li>
        <li>
          <button type="button"><i class="far fa-comment"></i>Messages</button>
        </li>
      </ul>
    </div>

  </div>
</div>
</div>



              
            
!

CSS

              
                $gray:#d2d2d2;
$blue: #339af0;
$red: #cf3455;
$black: #575757;
html{
  background: #f3f3f3;
  font-family: 'Roboto', sans-serif;
  min-height: 100%;

  &:before{
    content:'';
    position:absolute;
    width:50%;
    height:100%;
    left:0;
    top:0;
    background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/230827/background-full.png) no-repeat;
    background-size:cover;
    z-index:1;
  }

  &:after{
    content:'';
    position:absolute;
    width:50%;
    height:100%;
    right:0;
    top:0;
    background: $blue;
    z-index:1;
  }
}


button{
  background:transparent;
  padding:0;
  margin:0;
  border:none;
  cursor:pointer;
  outline:none;
}

.mobile-wrapper{
  width:300px;
  margin-bottom: 50px;
  position:absolute;
  top:50px;
  left:50%;
  transform:translateX(-50%);
  z-index:2;
  box-shadow:0 0 30px rgba(0,0,0, 0.5);
  border-radius:25px;

  .mobile{
    width: 100%;
    padding-bottom: 216%;
    background: black;
    border-radius: 25px;

    .photo{
      border-radius:0 0 15px 15px;
      background:black;
      width:40%;
      height:6%;
      position: absolute;
      left: 50%;
      top: 0%;
      transform: translateX(-50%);
      z-index:1;
      display:flex;
      align-items:center;
      justify-content:center;
      flex-direction:row-reverse;

      &:after{
        content: '';
        width: 40%;
        padding-bottom: 5%;
        border-radius: 20px;
        background: #191919;
        border: 2px solid #191919;
        display: block;
      }

      &:before{
        content: '';
        width: 8%;
        padding-bottom: 8%;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
        border: 2px solid #212121;
        display:block;
        margin-left:10px;
      }
    }

    .screen{
      border-radius: 20px;
      width: 94%;
      height: 97%;
      background: white;
      background-size: cover;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      display: flex;
      overflow: hidden;

      .os-header{
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        display: flex;
        justify-content: space-between;
        z-index: 999;
        background:$blue;

        .notch-left,
        .notch-right{
          color: white;
          padding: 10px;
          display:flex;
          align-items: center;

          > * {
            font-size: 12px;
            padding: 0 4px;
          }
        }
      }

      .header{
        position:absolute;
        top:0;
        width:100%;
        z-index:6;
        transition:all ease 500ms;

        .navbar{
          padding-top:calc(34px + 15px );
          display:flex;
          background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/230827/background.png');
          background-position:center center;
          background-size:cover;
          background-color:$blue;
          padding-left: 10px;
          padding-right: 10px;
          padding-bottom:15px;
          justify-content:space-between;
          align-items:center;

          .nav-toggle{
            width: 25px;
            height: 20px;
            position: relative;

            span{
              display: block;
              height: 3px;
              background: white;
              position: absolute;
              border-radius: 5px;
              transition:all ease 250ms;

              &:nth-child(1){
                top:0;
                left:0;
                width:100%;
              }

              &:nth-child(2){
                top:50%;
                left:0;
                transform:translateY(-50%);
                width:75%;
              }
              &:nth-child(3){
                bottom:0;
                left:0;
                width:100%;
              }
            }
          }

          .logo{
            color:white;
            font-weight:100;
            text-transform:uppercase;
            letter-spacing:2px;
          }

          .user{
            img{
              width: 30px;
              height: 30px;
              border-radius: 50%;
              display: block;
            }
          }
        }
      }
      .aside {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        background: #339af0;
        z-index: 5;
        overflow: auto;
        width: 100%;
        transform:translateX(-100%);
        transition:all ease 500ms;


        ul {
          list-style: none;
          padding: 0;
          margin: 0;
          padding-top: 95px;

          li {
            cursor:pointer;
            padding: 20px 20px;
            color: white;
            display: flex;
            align-items: center;
            font-weight: 100;
            position: relative;

            i {
              font-size: 30px;
              margin-right: 25px;
            }
          }
        }
      }
      .content{
        padding: 0 10px;
        padding-top:98px;
        padding-bottom:60px;
        display: flex;
        flex-wrap: wrap;
        overflow: auto;
        position: relative;
        flex: 1;
        width: 100%;

        > span{
          display:block;
          background-color:$gray;
          margin:10px 0;
          border-radius:10px;

          &.block-title{
            width:100%;
            height:20px;
          }

          &.block-text{
            width:100%;
            height:150px;

            &.semi{
              width:calc(50% - 10px);
              margin:5px;
            }
          }
        }
      }

      .footer{
        position:absolute;
        bottom:0;
        width:100%;
        background:white;
        box-shadow: 0 0 5px rgba(48, 29, 32, 0.2);
        z-index:5;

        ul{
          list-style:none;
          display:flex;
          margin:0;
          padding:0;

          li{
            width:100%;

            button{
              width: 100%;
              background: transparent;
              padding: 20px 0;
              border: none;
              font-size: 0px;
              outline:none;
              position:relative;

              &.active{
                i{
                  color:$black;
                  font-weight:bold;
                }
              }

              &.notification{
                i{
                  color:$blue;
                  font-weight:bold;
                }

                &:before{
                  content: attr(data-notification);
                  font-size: 10px;
                  position: absolute;
                  top: 20%;
                  right: 20%;
                  display: block;
                  color: $blue;
                  font-weight: bold;
                  width: 15px;
                  text-align: left;
                }
              }

              i{
                color:$gray;
                font-size:20px;
              }
            }
          }
        }
      }
    }

  }
}

body.open{
  .mobile-wrapper .mobile .screen{
    .header .navbar .nav-toggle{
      span{
        &:nth-child(1) {
          transform: translateY(-50%) rotate(-45deg);
          transform-origin: bottom left;
          width: 50%;
          top: 50%;
        }

        &:nth-child(3) {
          transform: translateY(50%) rotate(45deg);
          transform-origin: top left;
          width: 50%;
          bottom: 50%;
        }
      }
    }

    .aside{
      transform:translateX(0%);

      ul li{
        animation: fadeInLeft ease 500ms;
        animation-fill-mode: forwards;
        opacity:0;

        @for $i from 1 to 5 {
          &:nth-child(#{$i}) { animation-delay: $i * 0.1s; }
        }
      }
    }
  } 

}


@-webkit-keyframes fadeInLeft {
  0% {
    opacity: 0;
    -webkit-transform: translate3d(-100%,0,0);
    transform: translate3d(-100%,0,0)
  }

  to {
    opacity: 1;
    -webkit-transform: translateZ(0);
    transform: translateZ(0)
  }
}

@keyframes fadeInLeft {
  0% {
    opacity: 0;
    -webkit-transform: translate3d(-100%,0,0);
    transform: translate3d(-100%,0,0)
  }

  to {
    opacity: 1;
    -webkit-transform: translateZ(0);
    transform: translateZ(0)
  }
}
              
            
!

JS

              
                // Function for scrolling header

function scrollHeader(){
  var header = document.getElementById('header'),
      headerHeight = header.offsetHeight, // Header height
      content = document.getElementById('content'),
      previousScroll = content.scrollTop; // Get onload Scrolling

  content.onscroll = function(){
    currentScroll= content.scrollTop;  // Get the current scrolling position

    // Hide the header only if the header height is scroll
    if ( currentScroll > headerHeight){ 
      if ( currentScroll > previousScroll){
        header.style.transform = 'translateY(-'+ headerHeight +'px)'; // Hide header
      } else {
        header.style.transform = 'translateY(0)'; // Show header
      }
    }
    previousScroll = currentScroll;
  };
}scrollHeader(); //init function


// Function to toggle the menu 

function toggleMenu(){
  var navToggle = document.getElementById('nav-toggle');

  navToggle.onclick = function(){
    document.body.classList.toggle("open");
  };
} toggleMenu(); // init function

// Function for real clock

function updateClock() {
  var now = new Date(), // current date
      time = now.getHours() + ':' + now.getMinutes(),
      target = document.getElementById('time');

  // set the content of the element with the ID time to the formatted string
  target.innerHTML = [time];

  // call this function again in 1000ms
  setTimeout(updateClock, 1000);
} updateClock(); // init function

              
            
!
999px

Console