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 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

              
                <html lang="en">

<head>
  <meta charset="UTF-8" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
  <title>Document</title>
</head>

<body>
  <div class="flex-col-container">
    <div class="quotebox">
      <div class="text-center">
        <div class="quote-flex">
          <div class="quote__quotemark qm--up">&#x201C</div>
          <div class="quotebox__quote"></div>
          <div class="quote__quotemark qm--bottom">&#x201D</div>
        </div>
        <footer class="quote__sig"></footer>
      </div>
      <div class="quotebox__interactive-container">
        <div class="ic__social-links">
          <div class="solink btn twitter"
               title="You twit!@" id="twitter">
<!--    href="https://twitter.com/intent/tweet?text=" target="_blank" -->
             
            <i class="fa fa-twitter"></i>
          </div>
          <a id="tumblr"
             class="solink btn tumblr"
             target="_blank"
             title="Use your tumb!">
            <i class="fa fa-tumblr"></i>
          </a>
        </div>
        <div class="ic__separator"></div>
        <div class="ic__new-quote btn">new quote</div>
      </div>
      <div class="ic_project_notes text-center">
        <hr>
        This page was constructed as a drill for FCC, following design ideas of <a href="https://codepen.io/FreeCodeCamp/full/bELoPJ">FreeCodeCamp</a> with minor personal tweaks.
      </div>
    </div>
    <footer>by OBS & <a href="https://quotesondesign.com/api-v4-0/" title="quotes from quotesondesign.com" style="color: #9fcc25;">quotesondesign.com</a></footer>
  </div>
</body>

</html>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=PT+Serif:400,700);
@import url(https://fonts.googleapis.com/css?family=UnifrakturMaguntia);

$primary-color: #548678;
$hover-color: #447668;

html {
  font-size: 67.5%;
  box-sizing: border-box;
  transition: 0.5s linear;
}

body {
  background-color: $primary-color;
  color: $primary-color;
  margin: 0;
  padding: 0;
  height: 100vh;
  font-family: 'PT Serif', serif;
  transition: 0.5s linear;
}

.flex-col-container {
  display: flex;
  flex-flow: column nowrap;
  max-width: 43.750em;
  width:calc(100% - 5rem);
  
  margin: 50px auto;
  justify-content: center;
  align-items: streth;
}

.quotebox {
  display: flex;
  flex-flow: column nowrap;
  background-color: white;
  border-radius: 1rem;
  padding: 6rem 3rem 4rem;
  box-shadow: 0 0 0.5rem black;
}

.quote-flex {
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-around;
}

.quote__quotemark {
  font-family: 'UnifrakturMaguntia', cursive;
  font-size: 5rem;

}
.qm--up {
  align-self: flex-start;
  margin-top: -2rem;
}
.qm--bottom {
  align-self: flex-end;
  margin-bottom: -3rem;
}


.quotebox__quote {
  flex: 1 1 30px;
  font-family: auto;
  font-size: 4rem;
  font-weight: bold;
  text-align: center;
}

.quotebox__quote::first-letter {
    // font-family: 'UnifrakturMaguntia', cursive;
    font-size: 8rem;
    line-height: 6rem;
}

.quote__sig {
  color: inherit;
  font-size: 1.6rem;
  font-weight: normal;
  text-align: right;
  margin-bottom: 4rem;
}

.quotebox__interactive-container {
  display: flex;
  flex-flow: row nowrap;
}

.ic__separator {
  flex: 2 0 auto;
}

.btn {
  border-radius: 0.7rem;
  background-color: $primary-color;
  color: white;
  height: 4rem;
  font-size: 1.6rem;
}
.btn:hover {
  background-color: $hover-color;
  color: white;
  transition: 0.1s;
}
.btn:active {
  text-shadow: 1px 1px black;
  box-shadow: 2px 1px 0 2px black inset;
  color: white;
}

.solink {
  width: 4rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  line-height: 2.6rem;
}

footer {
  text-align: center;
  color: white;
  font-size: 1em;
}

.redbox {
  border: 3px red solid;
}

@media all and (max-width: 750px) and (min-width: 500px){
  .flex-col-container {
    width:calc(100% - 3rem);
  }
  html {
    font-size: 50%;
  }
  .btn {
    height: 4.2rem;
    font-size: 2rem;
  }
  .solink {
    width: 4.2rem;
  }
  .ic__new-quote {
    line-height: 2.6rem;
  }
}
@media all and (max-width: 499px) {
  .flex-col-container {
    width:calc(100% - 1.5rem);
  }
  html {
    font-size: 30%;
  }
  .quote__sig {
    font-size: 2rem;
  }
  .btn {
    height: 6rem;
    font-size: 2.5rem;
  }
    .solink {
    width: 6rem;
  }
  .ic__new-quote {
    line-height: 2.6rem;
  }
}

              
            
!

JS

              
                //TODO:
//1. fix twitter/tumbler (special characters break code)
//2. better trnsition animation
//3. overflow fix for large quotes.

$.ajaxSetup({ cache: false }); // new data on click
// $.ajaxSetup({ async: false }); // temporary for fixing sync issues.

var colors = [
  '#16a085',
  '#27ae60',
  '#2c3e50',
  '#f39c12',
  '#e74c3c',
  '#9b59b6',
  '#FB6964',
  '#342224',
  '#472E32',
  '#BDBB99',
  '#77B1A9',
  '#73A857'
];
var colors2 = [
  '#008065',
  '#078e40',
  '#0c1e30',
  '#d37c00',
  '#c72c1c',
  '#7b3996',
  '#dB4944',
  '#140204',
  '#270E12',
  '#9D9B79',
  '#579189',
  '#538837'
];
var cidx; // color index
var quote; var author;
var req;

function inIframe () { try { return window.self !== window.top; } catch (e) { return true; } }


function getAutomaticNewQuote() {
  getNewQuote(setNewQuote);
  newColor();
  // setTimeout(getAutomaticNewQuote,10000);
}

function getNewQuote(callback) {
  $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", 
            function(data) {
    quote = data[0]["content"].replace(/<\/?p>/g, "");
    author = data[0]["title"];
    callback();
  });
}

function setNewQuote() {
  $(".quotebox__quote").html(quote);
  $(".quote__sig").html(" - " + author);
  
  // if(inIframe()) {
  //   var twitter_link = 'https://twitter.com/intent/tweet?text="'+encodeURIComponent(quote+" - " + author)+'"';
  //   var tumblr_link = "https://www.tumblr.com/widgets/share/tool?posttype=quote&tags=quotes&caption="+author + "&content=" + quote;
  //   // var twitter = document.getElementById('twitter');
  //   // var tumblr = document.getElementById('tumblr');
  //   $("#twitter").setAttribute("href", twitter_link);
  //   tumblr.setAttribute("href", tumblr_link);
  // }
}

function newColor() {
  cidx = Math.floor(Math.random() * colors.length);
  $('html').css("background-color", colors[cidx]);
  $('body').css("background-color", colors[cidx]);
  $('body').css("color", colors[cidx]);
  $('.btn').css("background-color", colors[cidx]);
  $('.btn').hover(
    function() {
      $(this).css("background-color", colors2[cidx]);
    },
    function() {
      $(this).css("background-color", colors[cidx]);
    });
}

$(".ic__new-quote").click(getAutomaticNewQuote);
$( document ).ready( function () {
  getAutomaticNewQuote();
  
  
  $("#twitter").click(function () {
    // if(!inIframe()) {
    // qoute for test
    // quote = quote.replace(/[;]/g, "something");
    // var txt2 = '"' + decodeURI(quote) + '" - ' + decodeURI(author); // : good, ' bad. isn&#8217;t
    // alert(quote);
    quote = decodeURI(quote);
  for(var key in twitter_percent_encoding_dict) {
    // alert(key);
    // alert(quote);
      quote = quote.replaceAll(key, twitter_percent_encoding_dict[key]); // TODO will this replace all of them?
    }
    
    
    var txt2 = ['"',quote,'" - ',decodeURI(author)].join(''); // : good, ' bad. isn&#8217;t
    // alert(txt2);
    
    // window.open('https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text='+txt1,"_blank");
    window.open('https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text='+txt2,"_blank");
    // }
  });

});

String.prototype.replaceAll = function(search, replacement) {
    var target = this;
    return target.replace(new RegExp(search, 'g'), replacement);
};

var twitter_percent_encoding_dict = {
  ' ': '%20',
  // '!': '%21',
  // '\\"': '%22',
  // '%': '%25',
  // '&': '%26',
  "'": "%27",
  // '[(]': '%28',
  // '[)])': '%29',
  // '*': '%2A',
  // '+': '%2B',
  // ',': '%2C',
  // '/': '%2F',
  // ':': '%3A',
  // '=': '%3D',
  // '?': '%3F',
  // '\@': '%40',
  ';': '%3B',
  // '\[': '%5B',
  // '\]': '%5D',
  // '|': '%7C',
  // '~': '%7E',
  
  // "’": 
  '’': "%27",  //TODO will this work?
  '/[<]//?em[>]/': '',
  '“': '%93',
  "&#8220": '%93',
  
  '”': '%94'
};


//jQuery -- faster development
//Native -- better performance - see: http://jsperf.com/jquery-vs-native-element-performance
//failed to translate

              
            
!
999px

Console