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="content"> 
  <h1>Pseudo-elements ::before and ::after</h1>
  <h2>with <span>attr(title)</span> for tooltips</h2>
  <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolor, iste sed delectus consectetur <a href="#" title="Minimalistic School">minimaillum school in California</a>. Dignissimos, exercitationem ipsam repudiandae adipisci a facere excepturi earum eveniet voluptas tempora sapiente? Rerum, non?</p>
  <p>Quia possimus veritatis velit minus, deserunt non. Quisquam voluptatibus earum culpa harum quasi ut ab nulla voluptate? <a href="#" title="Nothihg compaire">Aspernatur provident explicabo</a> dolorem nobis similique itaque autem animi, reprehenderit deleniti, eos mollitia?</p>
  <p>Ipsa aliquid quibusdam aut non possimus temporibus rem obcaecati, illo nostrum, soluta voluptates cum <a href="#" title="Some Info">ducimus nemo unde</a> delectus magni expedita explicabo, dicta cumque vero quidem! Soluta consectetur architecto ex ipsum.</p>
</div>
<section>
  <div class="content">
    <h1>Pseudo-element ::before</h1>
  <h2>with <span>attr(data-text)</span> for hover-effect</h2>
     <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
    <p>Voluptatum ullam id eligendi esse nihil iusto labore repellat placeat sunt et veniam harum animi maxime doloribus consectetur, vitae, dolorum ea quas!</p>
     <button data-text="Best Offer">Learn More</button>
   </div>
</section>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Montserrat');
*, *:before, *:after {
  box-sizing: border-box;
  font-family: 'Montserrat', sans-serif;
}
body {
  margin: 0;  
}
section {
  background-color: #f9f0f1;
  padding: 20px 0;
  margin-bottom: 20px;
}
.content {
  width: 90%;
  margin: 20px auto;
}
span {
  color: #57f;
}

a {
  position:relative; 
  display: inline-block; 
}
a:before {
  content: attr(title);
  display: block;
  min-width: 120px;
  background-color: #000;
  color: #fff;
  padding: 5px 10px;
  text-align: center;
  font-size: 0.9em;
  position:absolute;
  top: -2.1em;
  left: 20%;
  opacity: 0;
  transform: translate(-50px);
  transition: .4s ease-out;
}

a:after {
  content:"";
  display: inline-block;
  border: 8px solid transparent;
  border-top-color: #000; 
  position:absolute;
  top: -2px;
  left: 45%;
  opacity: 0;
  transform: translate(-50px);
  transition: .4s ease-out;
}
a:hover:before, a:hover:after {
  opacity: 1;
  transform: translate(0);
}
button {
  cursor: pointer;
  padding: 10px 20px;
  background-color: #c00;
  color: #fff;
  font-size: 1em;
  border: 1px solid #900;
  border-radius: 6px;
  box-shadow: 2px 2px #600;
  position: relative;
  overflow: hidden;
}
button:before {
  content: attr(data-text);
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: inherit;
  background-color: #600;
  transform: translate(-120%);
  transition: transform .6s;
}
button:hover:before {
  transform: translate(0);
}
              
            
!

JS

              
                
              
            
!
999px

Console