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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <div class="container">
  <div id="macbook-top">
    <div class="macbook-screen">
      <i class="fa fa-apple logo"></i>
      <div class="macbook-window">
        <div class="macbook-browser">
          <div class="content-navbar">
            <div id="top-menu">
              <div id="content-navbar-close"></div>
              <div id="content-navbar-minimize"></div>
              <div id="content-navbar-expand"></div>
            </div>
            <div id="below-menu">
              <div id="back-forward">
                <div id="back"></div>
                <div id="forward"></div>
              </div>
              <div id="url"></div>
              <div id="search"></div>
            </div>
          </div>
          <!-- Form content -->
          <div class="content-form">
            <form id="form-message" onsubmit="return submitForm()">
            <input type="text" class="form-control" placeholder="Name" name="firstname" data-validation-required-message="Please enter your first name.">
            <input type="email" class="form-control" placeholder="Email" name="email" data-validation-required-message="Please enter your email.">
            <input type="tel" class="form-control" placeholder="Phone Number" name="phone" data-validation-required-message="Please enter your phone address.">
            <input class="form-control" placeholder="Message" name="message" id="message" data-validation-required-message="Please enter some message." ></input>
            <input type="submit" id="submit" value="Send message!">
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div id="macbook-bottom">
    <div id="macbook-notch">
    </div>
  </div>
  <div id="macbook-bottom-edge">
  </div>
</div>
              
            
!

CSS

              
                @bg: #db7093;

* {
  margin: 0 auto;
  -webkit-user-select: none;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: @bg;
}

.container {
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  flex-direction: column;

  #macbook-top {
    position: relative;
    width: 650px;
    height: 400px;
    background-color: black;
    border: 4px solid white;
    border-radius: 1.5rem;

    // Desktop-only drawing. Hide if width < 500px
    @media screen and (max-width: 500px) {
      visibility: hidden;
    }

    .macbook-screen {
      position: relative;
      width: 585px;
      height: 337.5px;
      border: 32.5px solid black;
      border-radius: 1.4rem;
      
      // Apple logo animation
      @keyframes apple-logo-disappear {
        0% {
          opacity: 1;
        }
        100% {
          opacity: 0;
        }
      }
      
      .logo {
        position: absolute;
        left: 257.5px;
        top: 115px;
        font-size: 80px;
        color: #fff;
        //animation: apple-logo-disappear 1s;
        //opacity: 0;
      }
      
    }

    .macbook-window {
      
      @keyframes screen-boot-up {
        0% {
          opacity: 0;
        }
        100% {
          opacity: 1;
        }
      }
      // Boot-up animation
      animation: screen-boot-up 2.5s ease-in;
      position: relative;
      top: 5px;
      height: 310px;
      width: 100%;
      background-color: azure;
    }
    
    .macbook-window::before {
      content: "";
      position: absolute;
      background-color: lightblue;
      left: 285px;
      top: -22.5px;
      width: 7.5px;
      height: 7.5px;
      border-radius: 10px;
    }
    
    .macbook-window::after {
      content: "";
      position: absolute;
      background-color: white;
      left: 288.75px;
      top: -19.25px;
      width: 2.5px;
      height: 2.5px;
      border-radius: 10px;
      opacity: 0.4;
    }

    .macbook-browser {
      .content-navbar {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 28.5px;
        background-color: grey;

        #top-menu {
          display: flex;
          width: 100%;

          #content-navbar-close {
            position: relative;
            margin: 0;
            left: 7.5px;
            top: 4px;
            width: 7.5px;
            height: 7.5px;
            border-radius: 5px;
            background-color: red;
          }

          #content-navbar-minimize {
            position: relative;
            margin: 0;
            left: 15px;
            top: 4px;
            width: 7.5px;
            height: 7.5px;
            border-radius: 5px;
            background-color: yellow;
          }

          #content-navbar-expand {
            position: relative;
            margin: 0;
            left: 22.5px;
            top: 4px;
            width: 7.5px;
            height: 7.5px;
            border-radius: 5px;
            background-color: green;
          }
        }

        #below-menu {
          display: flex;
          width: 100%;

          #back-forward {
            position: relative;
            display: flex;
            top: 7.5px;
            left: 6.5px;
            margin: 0;
            height: 10px;
            width: 40px;
            background-color: azure;

            #back {
              position: relative;
              top: 0;
              left: 0;
              margin: 0;
              height: 10px;
              width: 20px;
              background-color: lightgray;
            }

            #back::before {
              content: "\f060";
              position: relative;
              font-family: FontAwesome;
              color: grey;
              top: -7.5px;
              left: 6.5px;
              font-size: 7.5px;
            }

            #forward {
              position: relative;
              top: 0;
              margin: 0;
              height: 10px;
              width: 20px;
              background-color: lightgray;
            }

            #forward::before {
              content: "\f061";
              position: relative;
              font-family: FontAwesome;
              color: grey;
              top: -7.5px;
              left: 6.5px;
              font-size: 7.5px;
            }
          }

          #url {
            position: relative;
            height: 10px;
            width: 400px;
            background-color: azure;
            top: 7.5px;
            left: 7.5px;
          }

          #url::before {
            content: "\f067";
            position: relative;
            font-family: FontAwesome;
            color: grey;
            top: -7.5px;
            left: 5px;
            font-size: 6px;
          }

          #search {
            position: relative;
            height: 10px;
            width: 110px;
            background-color: azure;
            top: 7.5px;
            left: 0.5px;
            border-radius: 5px;
          }

          #search::before {
            content: "\f002";
            position: relative;
            font-family: FontAwesome;
            color: grey;
            top: -7.2px;
            left: 4px;
            font-size: 7px;
          }
        }
      }

      .content-form {
        positioon: relative;
        display: flex;
        height: 275px;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        // Desktop-only drawing. Hide if width < 500px
        @media screen and (max-width: 500px) {
          visibility: visible;
        }

        form {
          display: flex;
          flex-direction: column;
          width: 75%;

          input {
            width: 100%;
            margin: 7.5px 0;
            font-family: Noto Sans;
          }

          #message {
            padding-bottom: 40px;
          }

          #submit {
            width: 30%;
            align-self: center;
            margin-top: 20px;
          }
        }
      }
    }
  }

  #macbook-bottom {
    position: relative;
    width: 800px;
    height: 23.75px;
    background-color: grey;
    bottom: 15px;
    z-index: 10;
    overflow: hidden;

    // Desktop-only drawing. Hide if width < 500px
    @media screen and (max-width: 500px) {
      visibility: hidden;
    }
  }

  #macbook-bottom::before {
    content: "";
    position: absolute;
    left: 45px;
    width: 725px;
    height: 23.75px;
    background-color: darkgrey;
    overflow: hidden;
  }

  #macbook-bottom::after {
    content: "";
    position: absolute;
    right: 0;
    width: 35px;
    height: 23.75px;
    background-color: azure;
  }

  #macbook-notch {
    position: absolute;
    left: 300px;
    height: 12.5px;
    width: 200px;
    background: linear-gradient(to left, #c0c0c0 50%, #e5e4e2 50%);
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
  }

  #macbook-bottom-edge {
    position: absolute;
    bottom: 15px;
    width: 700px;
    height: 20px;
    position: relative;
    border-right: 50px solid transparent;
    border-top: 17.5px solid #c0c0c0;
    border-left: 50px solid transparent;
    box-sizing: content-box;
    z-index: 3;

    // Desktop-only drawing. Hide if width < 500px
    @media screen and (max-width: 500px) {
      visibility: hidden;
    }
  }
}

              
            
!

JS

              
                // Desktop only drawing - Defaults to form only on mobile
// Form submission handler --->
function submitForm(){
  const forminputs = Array.from(document.getElementById('form-message'));
  const valuesObject = forminputs.reduce((acc, el) => {
    if (el.name) { acc[el.name] = el.value; };
    return acc;
  }, {});
  alert(`Thanks for your message! Here is your data: \nName: ${valuesObject.firstname}\nEmail: ${valuesObject.email}\nPhone Number: ${valuesObject.phone}\nMessage: ${valuesObject.message}`);
  return false;
}
              
            
!
999px

Console