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

              
                <h1>Multi-Button CodePen Challenge - Jan 2020</h1>

<div class="multi-cont">
  <input type="text" class="text-cont" value="Edit me!">
  <div class="multi-button">
    <div class="multi-button__trigger"><div><i class="fas fa-pencil-alt"></i> Edit</div></div>
    <div class="multi-button__pane">
      <button data-fxn="cut"><i class="fas fa-cut"></i> Cut</button>
      <button data-fxn="copy"><i class="fas fa-copy"></i> Copy</button>
      <button data-fxn="paste"><i class="fas fa-paste"></i> Paste</button>
    </div>
  </div>
</div>
              
            
!

CSS

              
                $btn-radius: 60px;
$btn-color: #333;
$font-stack: 'Source Sans Pro', sans-serif;

body {
  height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  font-family: $font-stack;
  background-image: url(https://assets.website-files.com/5bfd1275cc56e15ce750b18e/5c289afb9a15754a65893a49_22.%20Shalimar.jpg);
  background-size: cover;
  background-position: bottom;
}

h1 {
  position: absolute;
  bottom: 10px;
  right: 20px;
  font-size: 20px;
  line-height: 1;
  color: rgba(#333, 0.7);
  transform: skew(-20deg);
}

.multi-cont {
  display: flex;
  align-items: center;
  
  input {
    width: 300px;
    height: 40px;
    font: $font-stack;
    border: none;
    -webkit-appearance: none;
    box-shadow: 0px 0px 4px rgba(black, 0.1);
    border-radius: 3px;
    padding: 5px 15px;
    font-size: 18px;
    font-weight: 300;
    margin-right: 10px;
  }
}

.btn-base {
  -webkit-appearance: none;
  border: 0px solid black;
  width: $btn-radius;
  height: $btn-radius;
  border-radius: 100%;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: white;
  font-size: 14px;
  transition: top 400ms, left 400ms, background 400ms, border 400ms, border-radius 400ms;
  cursor: pointer;
  font-family: $font-stack;
  box-shadow: 0px 2px 4px rgba(black, 0.4);
  background: $btn-color;
  
  i {
    width: 100%;
    margin-bottom: 3px;
  }
  
  &:hover {
    background: #555;
  }
}

.multi-button {
  $self: &;
  
  position: relative;
  padding: 10px 0 10px 10px;
  border-radius: $btn-radius 0 0 $btn-radius;
  transition: background 400ms;
  
  button {
    @extend .btn-base;
  }
  
  &__trigger {
    @extend .btn-base;
    position: relative;
    z-index: 2;
  }
  
  &__pane {
    position: absolute;
    top: 0px;
    left: calc(100% + 20px);
    display: flex;
    pointer-events: none;
    opacity: 0;
    transition: opacity 400ms, left 400ms, top 400ms;
    background: #888;
    padding: 10px 10px 10px 0;
    border-radius: 0 $btn-radius $btn-radius 0;
    button {
      border-radius: 0;
      border-left: 1px solid rgba(white,0.5);
      
      &:last-of-type {
        border-radius: 0 100% 100% 0;
      }
    }
  }
  
  &:hover, &.active{
    background: #888;
    #{$self}__trigger {
      border-radius: 100% 0 0 100%;
    }
    #{$self}__pane {
      opacity: 1;
      pointer-events: all;
      left: 100%;
      top: 0;
    }
  }
  
  &.active {
    #{$self}__trigger {
      background: #444;
    }
  }
}
              
            
!

JS

              
                $('.multi-button__trigger').on('click',function(){
  $(this).parent().toggleClass('active');
});

$('.multi-button__pane button').on('click',function(){
  let fxn = $(this).data('fxn');
  switch(fxn) {
    case 'copy':
      /* Get the text field */
      var copyText = $('.text-cont')[0];

      /* Select the text field */
      copyText.select();
      copyText.setSelectionRange(0, 99999);

      /* Copy the text inside the text field */
      document.execCommand("copy");

      /* Alert the copied text */
      alert("Copied the text: " + copyText.value);
      break;
  }
});
              
            
!
999px

Console