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

              
                <body>

  <h1>freeCodeCamp - Quote Machine</h1>
  <section>
    <div id="quotation">
    </div>
    <div id="author">
    </div>
    <div class="buttons">
      <a href="#" id="tweet">
        <svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300.00006 244.18703" height="24.5" width="30" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
 <g style="" transform="translate(-539.18 -568.86)">
  <path d="m633.9 812.04c112.46 0 173.96-93.168 173.96-173.96 0-2.6463-0.0539-5.2806-0.1726-7.903 11.938-8.6302 22.314-19.4 30.498-31.66-10.955 4.8694-22.744 8.1474-35.111 9.6255 12.623-7.5693 22.314-19.543 26.886-33.817-11.813 7.0031-24.895 12.093-38.824 14.841-11.157-11.884-27.041-19.317-44.629-19.317-33.764 0-61.144 27.381-61.144 61.132 0 4.7978 0.5364 9.4646 1.5854 13.941-50.815-2.5569-95.874-26.886-126.03-63.88-5.2508 9.0354-8.2785 19.531-8.2785 30.73 0 21.212 10.794 39.938 27.208 50.893-10.031-0.30992-19.454-3.0635-27.69-7.6468-0.009 0.25652-0.009 0.50661-0.009 0.78077 0 29.61 21.075 54.332 49.051 59.934-5.1376 1.4006-10.543 2.1516-16.122 2.1516-3.9336 0-7.766-0.38716-11.491-1.1026 7.7838 24.293 30.355 41.971 57.115 42.465-20.926 16.402-47.287 26.171-75.937 26.171-4.929 0-9.7983-0.28036-14.584-0.84634 27.059 17.344 59.189 27.464 93.722 27.464"/>
 </g>
</svg>
      </a>
      <a href="#" id="newQuote">New Quote</a>
    </div>
  </section>
  <footer>
    created by tamasc
  </footer>
</body>
              
            
!

CSS

              
                body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #403A47;
  color: #06D8FF;
}

section {
  font-family: 'Indie Flower', cursive;
  width: 450px;
  min-height: 240px;
  border: 3px solid #06D8FF;
  border-radius: 25px;
  margin:110px 0 50px 0;
  position: relative;
}

h1 {
  font-family: 'Bungee', cursive;
  top: 25px;
  left: calc(50% - 270px);
  line-height: 45px;
}

h1, footer {
  position: absolute;
}

footer {
  right: 40px;
  bottom: 5%;
}

section div {
  margin: 25px;
  font-size: 1.25rem;
  position: relative;
}

#quotation:before {
  content:'"';
  position: absolute;
  top: -15px;
  left: -15px;
  font-size: 45px;
}

#quotation:after {
  content:'"';
  position: absolute;
  bottom: -13px;
  right: -5px;
  font-size: 45px;
  transform: rotate(180deg);
}

#quotation {
  text-align: center;
}

#author {
  text-align: right;
  font-family: 'Slabo 27px', serif;
}

.buttons a{
  display: inline-block;
  text-decoration: none;
  border: 0px solid #06D8FF;
  border-radius: 5px;
  padding: 8px;
  margin: 5px;
}

a:link, a:active, a:visited {
  color: #403A47;
  background-color: #06D8FF;
}

a:hover {
  background-color: #18E9FF;
}

.buttons {
  position: absolute;
  bottom: -10px;
  font-family: 'Slabo 27px', serif;
}

#tweet svg {
  fill: #403A47;
  margin: 0px;
  padding: 0px;
  position: relative;
  bottom: -5px;
}


              
            
!

JS

              
                var quoteData = {};

$(document).ready(function() {
  $.ajaxSetup({
    cache: false
  });
  getQuote();
  $("#newQuote").click(getQuote);
  $("#tweet").click(tweetQuote);
});

function getQuote() {
  $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1", function(data) {
    displayQuote(data);
    qouteData = data
  })
}

function displayQuote(data) {
  $("#quotation, #author").fadeOut(300, function(){
    $("#quotation").html(data[0].content);
      if (!data[0].title) {
        $("#author").html("unknown author");
      } else {
        $("#author").html(data[0].title);
      }
   })
  $("#quotation, #author").fadeIn(1800)
  quoteData = data;
}

function tweetQuote() {
  window.open("https://twitter.com/intent/tweet?text=" + "\"" + encode(
    quoteData[0].content.slice(3, quoteData[0].content.length - 5)) + "\", " + quoteData[0].title, "_blank");
}

function encode(str) {
  return encodeURIComponent(decodeURIComponent(str).replace(/&#([0-9]{0,4});/g, function(match, numStr) {
    var num = parseInt(numStr, 10);
    console.log("match");
    return String.fromCharCode(num);
  }))
}
              
            
!
999px

Console