cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="spacer"></div>
<!-- Don't add the above spacer to your code, it's just so you can see the example in CodePen -->


<span class="button_container">
  <span class="my_button">Test Button 1</span>
  <div class="my_target">
    Test Target 1 
    <span class="close_button">close</span>
  </div>
</span>
      
<span class="button_container">
  <span class="my_button">Test Button 2</span>
  <div class="my_target">
    Test Target 2
    <span class="close_button">close</span>
  </div>
</span>

            
          
!
            
              .button_container {
    display: inline-block;
    position: relative;
}
.my_button {
    padding: 1em;
    background-color: #ffa457;
    display: inline-block;
    position: relative;
    cursor: pointer;
}
.my_button:hover {
    background-color: #ff6439;
}
.my_target {
    background-color: #f3f3f3;
    padding: 2em;
    border:1px solid #e5e5e5;
    width: 10em;
    display: none;
    position:absolute;
    z-index:2;
    bottom: 110%;
    left: 0;
    box-shadow: 0 0 8px rgba(0,0,0,0.1);
}
.my_target:after {
    content:'';
    display: block;
    height: 0;
    width: 0;
    position: absolute;
    top:100%;
    left:10%;
    border-top:12px solid #f3f3f3;
    border-left:12px solid transparent;
    border-right:12px solid transparent;
    border-bottom: none;
}
.close_button {
    background-color: #000;
    color: #fff;
    padding:0.4em 0.5em;
    display: inline-block;
    cursor: pointer;
    text-transform: uppercase;
    position: absolute;
    top:0.4em;
    right: 0.4em;
    font-size: 0.8em;
    line-height: 100%;
    opacity: 0.5;
    border-radius: 0.2em;
}
.close_button:hover {
    opacity: 1.0;
}


.spacer {
  /* NOTE: This element isn't useful for your code, I'm just adding it to give space in the CodePen to see the tooltip show up */  
  height:120px;
  width:100%;
}
            
          
!
            
              $(".my_button").click(function() {
    if ( $(this).next(".my_target").is(":visible") ) {
      $(this).next(".my_target").hide();
      return;
    }
    $(".my_target").hide();
    $(this).next(".my_target").show();
});

$(".close_button").click(function(){
    $(this).parent().hide();
});
            
          
!
999px
Loading ..................

Console