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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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">
  <input type="text" placeholder="Lorem ipsum dolor"><button class="copied" data-tooltip="Copy" data-clicked="Copied!"><i class="fas fa-copy"></i></button>

<i class="disclaimer">Disclaimer: doesn't actually copy anything.</i>
<div>
              
            
!

CSS

              
                /*
Create a psuedo-element to display the tooltip with
some basic styling to make it visible when displayed,
but hide it by default.
*/
.copied::after {
  /* Make sure the psuedo-element exists in the DOM */
  content: "";
  
  /* Hide the tooltip by default */
  opacity: 0;
  
  /* Some bacis styling to make it visible */
  background-color: #666;
  color: #FFF;
}

/*
When the button is hovered, display the normal tooltip.
*/
.copied:hover::after {
  /* Set the value of the tooltip */
  content: attr(data-tooltip);
  
  /* Make the tooltip visible ... */
  opacity: 1;
  
  /* ... with a small animation */
  transition: .2s ease opacity;
}

/*
When the button has been clicked (it obtains :focus) apply
two animations to:
  1) keep the tooltip visible temporarily (even without hover)
  2) restore the original tooltip text after 1.
*/
.copied:focus::after {
  animation-name:
    /* Animation: tooltip-opacity 
     * Ensures the tooltip remains visible for the duration
     * of the animation.
     */
    tooltip-opacity,
    
    /* Animation: tooltip-content
     * Initially change the tooltip text to "data-clicked"
     * and change it back to "data-tooltip" when the tooltip
     * disappears again.
     */
    tooltip-content;
  
  animation-fill-mode:
    /* Animation: tooltip-opacity 
     * After the animation ends, resume to whatever opacity
     * the tooltip should have based on other selectors.
     */
    none,    
    
    /* Animation: tooltip-content
     * After the animation ends make sure the "data-clicked"
     * text is displayed. This is required so that "data-
     * clicked" text can stay active for the duration of the
     * animation *AND* the text is set back to "data-tooltip"
     * when hovering the button again later.
     */
    forwards;

  /* Make sure both animations take the same amount of time */
  --animation-duration: 2.5s;
  animation-duration:
    var(--animation-duration),
    var(--animation-duration);
}

/*
When the button is being clicked (it obtains :active) 
reset any previous animations. This allows the animations
in .copied:focus::after to take effect again.
*/
.copied:active::after {
  animation-name: none;
}

@-webkit-keyframes tooltip-opacity {
  /* Make sure the tooltip is visible */
  0%   { opacity: 1; }
  
  /* Keep it visible almost to the end */
  95%  { opacity: 1; }
  
  /* Slowly fade away when the animation ends */
  100% { opacity: 0; }
}
@-webkit-keyframes tooltip-content {
  /* Show the "data-clicked" text when the animation starts ... */
  0%   { content: attr(data-clicked); }
  
  /* ... keep that text for as long as possible */
  99%  { content: attr(data-clicked); }
  
  /* Resume to the default tooltip text when the animation ends. */
  100% { content: attr(data-tooltip); }
}

/** STYLING **/

button,
input {
  border: 1px solid gray;
  border-radius: 6px 0 0 6px;
  box-sizing: border-box;
  display: inline-block;
  height: 36px;
  margin: 0;
}

button {
  background-color: #DDD;
  border-left: none;
  border-radius: 0 6px 6px 0;
  padding: 6px 12px;
}
button:hover {
  background-color: #888;
  color: #FFF;
}

input {
  border-right: none;
  padding: 6px 8px;
}
input:focus {
  box-shadow: 0 0 0 .2rem rgba(0, 123, 255, .25); /* courtesy of Boostrap */
}

.copied {
  overflow: visible;
  position: relative;
}
.copied::after {
  border-radius: 4px;
  left: 50%;
  padding: 6px 12px;
  position: absolute;
  top: calc(100% + 6px);
  transform: translateX(-50%);
}

/** LAYOUT **/

html, body {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
}
.container {
  height: 78px;
  position: relative;
}
.disclaimer {
  bottom: 0;
  font-family: sans-serif;
  font-size: 10px;
  font-style: italics;
  position: absolute;
  right: 0;
}
              
            
!

JS

              
                
              
            
!
999px

Console