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

              
                <head>
  <link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
</head>
<body>
  <div id="quote-box">
    <div id="quote" class="standard-text">
      <i class="fa fa-quote-left">&nbsp&nbsp</i><span id='text'><p>test this is a test to see what happens with a lot of text</p></span>
    </div>
    <div id="author" class="standard-text">
      Author author
    </div>
    <div id="right-buttons-hover" class="highlight">
      New Quote
    </div>
    <div id="right-buttons" class="standard" >
      New Quote
    </div>
    <div id="left-buttons" class="standard">
      <i class="fa fa-twitter" aria-hidden="true"></i>
    </div>
  </div>
</body>
              
            
!

CSS

              
                body {
  background-color: hsl(120, 68%, 67%);
  font-family: arial, sans-serif;
}
p {
  display: inline;
}
#quote-box {
  width: 25%;
  background-color: white;
  margin-top: 200px;
  margin-right: auto;
  margin-left: auto;
  text-align: center;
  padding: 50px 50px 70px 50px;
  border-radius: 2.5px;
}


#quote {
  padding-bottom: 25px;
  font-family: 'Raleway', sans-serif;
  font-size: 1.7em;
}
#author {
  text-align: right;
  font-size: 1.2em;
  padding-bottom: 30px
}
#right-buttons,
#right-buttons-hover,
#left-buttons {
  line-height: 40px;
  padding-right: 10px;
  padding-left: 10px;
  height: 40px;
  display: inline-block;
  position: relative;
  border-radius: 2.5px;
  color: white;
}
#right-buttons:hover,
#left-buttons:hover,
#right-buttons-hover:hover{
  cursor: pointer;
}
#right-buttons,
#right-buttons-hover{
  float: right;
}
#left-buttons {
  float: left;
  font-size: 1.5em;
}

.standard {
  background-color: hsl(120, 68%, 67%);
}
.standard-text {
  color: hsl(120, 68%, 67%);
}
.highlight {
  background-color: hsl(120, 68%, 67%);
}
              
            
!

JS

              
                /*This isn't the final, this is just a fork with a few bugs */

$(document).ready(function() {
  var $hue = Math.floor((Math.random() * 360) + 1);
  
  $("#right-buttons-hover").hide()
  
  /*this will hold quote dictionaries*/
  
  var quoteBank = [];
  $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=30&callback=", function(data) {

    data.forEach(function(val) {
      quoteBank.push(val);
    })
    changeQuote();
  });
  
  /*changes the theme of the website */
  function changeColor() {
    $hue = Math.floor((Math.random() * 360) + 1);
    $("body, .standard").animate({
      "background-color": "hsl(" + $hue + ", 68%, 67%)", queue: false
    }, 1500);
    $(".standard-text").animate({
      "color": "hsl(" + $hue + ", 68%, 67%)", queue: false
    }, 1500);
    /* This didn't work the way I wanted it to but I like how it checks for hover and wanted to keep the code for reference
    
    if ($('#right-buttons:hover').length != 0) {
      $('#right-buttons').animate({"background-color":  "hsl("+$hue+", 68%, 55%)"}, 1500);*/
    $(".highlight").animate({
      "background-color": "hsl(" + $hue + ", 68%, 55%)", queue: false
    }, 1500);
  }
  
  function changeQuote() {
    /*
    Generates a random quote and person from the randomQuote array
    */

    var randomQuote = Math.floor((Math.random() * 29))
    $("#quote").fadeOut();
    $("#text").html(quoteBank[randomQuote].content);
    $("#author").html(quoteBank[randomQuote].title);
    $("#quote").fadeIn();
    $("#author").fadeIn();
    
  
    /* 
    Also doesn't work. The webaddress part works in the browser. I'm not sure if this one refreshes on right-buttons-hover click because I haven't gotten any input out of it. from https://forismatic.com/en/api/ 
    */
    /*
    $.getJSON("api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=json&lang=en", function(json) {
      $("#quote").html(json);
    });
    */
  }


  $("#left-buttons").hover(function() {
    $(this).css({
      "background-color": "hsl(" + $hue + ", 68%, 55%)"
    })
  }, function() {
    $(this).css({
      "background-color": "hsl(" + $hue + ", 68%, 67%)"
    })
  });
   
  changeColor();
  console.log(quoteBank.length)
  /*this changeQuote() call breaks all jQuery below it and does not execture if placed at the very bottom of the jQuery inside of the document ready function*/
  /*
  changeQuote(); */
  
  //I'm making this a little messy because the changeColor function was not working well with a simple .css change for #right-buttons.  The highlighted or standard color would "freeze" during the animation and I would need to move the mouse back over the button to corret the coloration.  I want the highlight color to be darker, so I could not simply change the opacity.
  $("#right-buttons, #right-buttons-hover").hover(
    function() {
      $("#right-buttons").hide()
      $("#right-buttons-hover").show()
    },
    function() {
      $("#right-buttons").show()
      $("#right-buttons-hover").hide()
    });

  $("#right-buttons-hover").on('click', function() {
    changeQuote();
    changeColor();
    
  });

});

              
            
!
999px

Console