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

              
                <header role="banner">
  <h1 class="visually-hidden">Base Apparel Coming Soon</h1>
  <a href="/" title="return to the homepage" id="logo">
    <img src="https://res.cloudinary.com/gb2020/image/upload/v1589217430/base%20apparel%20coming%20soon/logo_homs80.svg" alt="Base Apparel Logo">
  </a>
</header>
<section class="side-image"></section>
<main class="[ main ] [ flow ]">
  <h2>
   <span class="heading--pink">
      We're
   </span>
   coming soon
  </h2>
  <p>
    Hello fellow shoppers! We're currently building our new fashion store. 
    Add your email below to stay up-to-date with announcements and our launch deals.
  </p>
  <form action="/" class="[ form ] [ flow ]" method="POST" id="form">
    <div class="form__control">
      <input type="email"
             name="email"
             id="email"
             value=""
             autocapitalize="none"
             autocomplete="false"
             autocorrect="off"
             required
             pattern="[^@]+@[^\.]+\..+" />
      <label for="email">Email Address</label>
      <button class="button">
        <span class="visually-hidden">Submit email</span>
        <svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" width="12" height="20"><path fill="none" stroke="#FFF" stroke-width="2" d="M1 1l8.836 8.836L1 18.671" /></svg>
      </button>
      <div class="alert_icon"></div>
    </div>
  </form>
  <div aria-atomic="true" role="alert" class="form__alert"></div>
</main>
<footer>
  <p>Coded by <a href="https://codepen.io/garyb1" _target="blank">Gary Byrne</a></p>
</footer>
              
            
!

CSS

              
                /**
* Reset
**/

*, *:before, *:after {
  box-sizing: border-box;
}

/**
* Variables
**/

:root {
  --metric-rhythm: 2rem;
  --metric-interaction-padding: 0.6rem 0.6rem;
}

/**
* Base
**/

body {
  height: 100vh;
  font-family: 'Josefin Sans', sans-serif;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 65% 35%;
  grid-template-areas:
    "header side-image"
    "main side-image"
    "main side-image"
    "footer side-image";
  background-image: url('https://res.cloudinary.com/gb2020/image/upload/v1589217438/base%20apparel%20coming%20soon/bg-pattern-desktop_ohtovt.svg');
  background-size: 100% 100%;
}

/**
* Utilities
**/

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: auto;
  margin: 0;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  white-space: nowrap;
}

.flow {
  --flow-space: var(--metric-rhythm);
}

.flow > * + * {
  margin-top: 1em;
  margin-top: var(--flow-space);
}

/**
* Header
**/

header {
  grid-area: header;
  height: 100px;
  padding-top: 3rem;
  padding-left: 10rem;
}

/**
* Side
**/

.side-image {
  grid-area: side-image;
  background-image: url('https://res.cloudinary.com/gb2020/image/upload/v1589217439/base%20apparel%20coming%20soon/hero-desktop_qd7w4w.jpg');
  background-repeat: no-repeat;
  background-size: cover;
}

/**
* Main
**/

.main {
  grid-area: main;
  max-width: 800px;
  padding-left: 10rem;
}

h2 {
  font-size: 4rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  word-spacing: 100vw;
  line-height: 1.1em;
}

h2 .heading--pink {
  font-weight: 300;
  color: hsl(0, 36%, 70%);
  letter-spacing: 0.33em;
}

.main p {
  color: hsl(0, 36%, 70%);
  line-height: 1.5em;
  width: 49ch;
}

.form {
    --flow-space: 3.5rem;
}

.form__control {
  display: flex;
  position: relative;
  width: 48ch;
  border: 1px solid hsl(0, 36%, 70%);
  border-radius: 999px;
  transition: 0.2s;
  --flow-space: 0.5rem;
}

.form__control:focus-within {
  border-width: 2px;
}

.form__control label {
  position: absolute;
  text-transform: capitalize;
  height: 100%;
  color: hsl(0, 36%, 70%);
  display: flex;
  align-items: center;
  padding-left: 2rem;
  width: 100%;
  transition: 0.2s;
}

input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active  {
  -webkit-box-shadow: 0 0 0 30px white inset !important;
}

.form__control input {
  border: none;
  background-color: transparent;
  outline: 0;
  padding: 20px 0 20px 2rem;
  flex: auto;
}

input:focus + label, input:not([value=""]) + label {
    align-items: flex-start;
    opacity: 0.75;
    transform: translateY(-1.5rem);
}


.button {
  z-index: 1;
  background-image: linear-gradient(135deg, hsl(0, 80%, 86%), hsl(0, 74%, 74%));
  min-width: 7.5rem;
  border-radius: 999px;
  cursor: pointer;
}

.button:hover, .button:focus {
  filter: brightness(1.05);
  box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
  color: #fff;
  outline: 0;
}

.button svg {
  transform: translateY(1px); /* Optical adjustment */
}

/**
 * ALERT COMPONENT
 */

.form__alert {
    --flow-space: 0;
}

.alert {
  --alert-text: hsl(0, 36%, 70%);

  display: flex;
  align-items: flex-start;
  color: var(--alert-text);
  animation: slide-up 250ms ease;
}

.alert[data-state='success'] {
  --alert-text: green;
}

.alert__icon {
  font-size: 1.6em;
  flex-shrink: 0;
}

.alert__content {
  padding-left: 2rem;
}

.alert__content b {
  display: block;
}

/**
 * ANIMATIONS
 */
@keyframes slide-up {
  0% {
    opacity: 0;
    transform: translateY(0.4rem);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/**
* Footer
**/

footer {
  grid-area: footer;
  display: flex;
  justify-content: center;
}

footer a {
  color: hsl(0, 36%, 70%);
}

/**
* Media Query
**/

@media screen and (-ms-high-contrast: active) {
  input[type],
  button {
    border: 1px solid;
  }
}
  

@media(max-width: 1000px) {
  body {
    grid-template-columns: 100%;
    grid-template-areas:
      "header"
      "side-image"
      "main"
      "footer";
  }
  
  .side-image {
    min-height: 25rem;
    background-image: url('https://res.cloudinary.com/gb2020/image/upload/v1589217439/base%20apparel%20coming%20soon/hero-mobile_dv2qh6.jpg');
  }
  
  .main, header {
    padding: 2rem;
    width: 100vw;
    margin: 0 auto;
  }
  
  .main h2, .main p {
    text-align: center;
  }
  
  .main h2 {
    font-size: 3rem;
  }
  
  .main p, .form__control {
    width: 98%;
    margin: 0 auto;
  }
}

              
            
!

JS

              
                const renderAlert = (state = 'error') => {
  const messages = {
    error: 'Please provide a valid email',
    success: '<b>Yay! Thank you!</b> We’ve sent a confirmation link to your inbox.'
  };

  return `
  <div class="alert" data-state="${state}">
    <p class="alert__content">${messages[state]}</p>
  </div>
  `;
};


const init = () => {
  const emailElement = document.querySelector('#email');
  const formElement = document.querySelector('#form');
  const alertElement = document.querySelector('[role="alert"]');
  const validationRegex = new RegExp(
    emailElement.getAttribute('pattern') || '[^@]+@[^.]+..+',
    'i'
  );
  
  emailElement.removeAttribute('required');
  emailElement.removeAttribute('pattern');
  formElement.setAttribute('novalidate', '');
  
  formElement.addEventListener('submit', evt => {
    evt.preventDefault();

    if (!validationRegex.test(emailElement.value.trim())) {
      alertElement.innerHTML = renderAlert('error');
      emailElement.setAttribute('aria-invalid', 'true');
      return;
    }

    // POST YOUR FORM WITH AJAX OR WHATNOT THEN RUN THIS
    formElement.parentElement.removeChild(formElement);
    alertElement.innerHTML = renderAlert('success');
  });
}

init();
              
            
!
999px

Console