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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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 class="hover-container">
    <h1>Underline Link Effect</h1>
    <p><small>(hover over above text please)</small></p>
  </div>
  
  <p class="body-text">I made this little pen because I kept forgetting how to achieve this effect. </p>
  <p class="body-text"><strong>Note:</strong> Edit <code>transform-origin</code> to change how where the animation starts. It's currently set to <code>left</code>.<br /> <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin">Read more about this property on MDN.</a> </p>
</div>

              
            
!

CSS

              
                /* the code you want is around line 45  */

@import url("https://fonts.googleapis.com/css?family=Montserrat:400,700");

* {
  padding: 0;
  margin: 0;
}

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

body {
  font-family: Montserrat, sans-serif;
  height: 100%;
  min-height: 100vh;
  background-color: #ebf3ff;
}

.container {
  display: flex;
  flex-flow: column;
  width: 60%;
  height: 100vh;
  margin: 0 auto;
  align-items: center;
  justify-content: center;
}

.hover-container {
  text-align: center;
  margin-bottom: 2em;
}

.body-text {
  margin: 0.5em 0;
}

/* --- this is the code you probably want ---- */

h1 {
  border-bottom: 3px solid #ff8cbc;
  font-size: 3em;
  transition: all 0.25s linear;
  position: relative;
}

h1:before {
  content: "";
  display: block;
  width: 100%;
  height: 3px;
  background-color: #61a3ff;
  position: absolute;
  left: 0;
  bottom: -3px; /* this is to match where the border is */
  transform-origin: left; 
  transform: scale(0);
  transition: 0.25s linear;
/*   will-change: transform; */
}

h1:hover:before {
  transform: scale(1);
}
              
            
!

JS

              
                
              
            
!
999px

Console