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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <body>
<div class="container-fluid">
  
  <div class = "text-center">
    <div>
    <h1>Random Quotes Machine</h1>
  </div>
  
<div class = "text-center">
  <h3>You can click the button to get a random qoute</h3>
</div>
</div>
     
    <button class = "button btn btn-primary">Try it</button>

<div class="output">
  <h3 class = "quote"></h3> 
  <h4 class = "author"
</div>
</div>
  <a class="twitter-share-button" href="https://twitter.com/intent/tweet" data-size="large" target="_blank">
      <button type="button" class="btn btn-primary">Tweet it!</button>
    </a>
</body>

              
            
!

CSS

              
                
body {
  background: #1a7a70;
  color: #fff;
  font-family: "Oswald", Arial, sans-serif;
  text-align: center;
}
h1 {
  width: 100%;
  text-align: center;
  letter-spacing: 0.02em;
  margin: 2em 0;
}
h3 {
    margin: 1em 0;

}
.button {
   border: 2px solid transporent;
  
  &::after {
    width: 0%;
    height: 2px;
    display: block;
    background-color: red;
    content: " ";
    position: absolute;
    top: 34px;
    left: 50%;
    transition: left 0.2s cubic-bezier(0.215, 0.61, 0.355, 1), width 0.2s cubic-bezier(0.215, 0.61, 0.355, 1);
  }
  
  &:hover {
    &::after {
      width: 100%;
      height: 2px;
      display: block;
      background-color: #fff;
      content: " ";
      position: absolute;
      top: 34px;
      left: 0;
    }
  }
  
}

.output {
  background-color: white;
  color: black;
  font-variant: small-caps;
}
              
            
!

JS

              
                
function tweet(message) {
window.open('https://twitter.com/intent/tweet?text='   + encodeURIComponent(message));
}

var msg;
function tweetHandler() {
tweet($(msg).text()); 
}

function GetAQuote() {
 
  $.ajax({
    url: "https://random-quote-generator.herokuapp.com/api/quotes/random",
    type: 'get',
    data: {},
    datatype: 'json',
    success: function(data) {
     // quote = JSON.parse(data);
      msg = $(".quote").html('&quot;' + data.quote + '&quot;');
      $(".author").html(data.author);
      $(".button").html("Get a new quote");
    },
    error: function(err) {
      console.log(err);
    }  
  });
};

$(document).ready(function() {

  GetAQuote();
  
  $(".button").click( function(event){
      GetAQuote();
  });
  $('.twitter-share-button').on('click', tweetHandler);
});


//Code below works well if replace two last functions above 
/*
function GetAQuote() {
      $.getJSON("https://random-quote-generator.herokuapp.com/api/quotes/random", 
                // This API not requires any authetication or APIkey
      function(data) {
       msg = $(".quote").html('&quot;' + data.quote + '&quot;');
        $(".author").html(data.author);
        $(".button").html("Get a new quote");
    });
};

$(document).ready(function() {
  GetAQuote(); // Request random qoute directly after page loads
  $(".button").click( function(event) {
    GetAQuote();
  });
$('.twitter-share-button').on('click', tweetHandler);
});
*/
              
            
!
999px

Console