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

              
                <!--Importing Raleway font and font awesome -->
<header>
  <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Raleway" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</header>

<div>
<body id = "background" style = "background-color:#672E3B;">

<h1 class="text-center" style="margin-top:40px; color:#672E3B;">ALORA Random Quote Generator</h1>
<h1 class="text-center" style="margin-top: 400px; color:#672E3B; font-size: 12px;">Copyright © ALORA Design Studio 2017. All Rights Reserved.</h1>
  
<!--Division for the quote box -->
   <div class = "quotebox"> 
     <div >
       <h4 id = "initialMessage" class="text-center" style ="margin-top: 20px; ">BEWARE! You might get inspired by these quotes.</h4>
     <h4 id ="message" class="text-center" style="margin-top:60px; font-size:16px" ><i class="fa fa-quote-left"><span id="text"></span> </i></h4>
       <h4 id ="authorid" class=text-center style = "font-size: 17px;"></h4>
     </div>
     
     <div>
       <div class="col-xs-6">
    <button id ="button1" class="btn btn-primary center-block  button">Generate Quote</button>
         </div>
       <div class="col-xs-6">
       <a id ="tweet" target="_blank"><button id ="button2" class="btn btn-primary center-block  button"><i class="fa fa-twitter"> Tweet </i></button></a>
       </div>
       </div>
     
     
     </div>
  </div>
</body>
</div>
              
            
!

CSS

              
                
.quotebox{
  background-color: white;
  position: absolute;
  margin-left:-300px;
  margin-top:-130px;
  left: 50%;
  top: 50%;
  width: 600px;
  height: auto;
  border-radius: 4px;
  
}
.button{
  margin-top: 10%;
  margin-bottom: 10px;
  border-width: 0;
  background-color:#672E3B;
}

h4{
  font-size: 25px;
  
  }

body{
  font-family: Raleway;
}

h1{
  
  font-family: Raleway;
  font-size: 29px;  
  text-shadow: .5px .5px white;  
}
              
            
!

JS

              
                $(document).ready(function(){
  $("#button1").hover(function(){
    $(this).css("background-color", x );
  });
  $("#button1").on("click",changeColorQuote) 
});

//defining a global variable x for random colors and setting initial color.
var x = "#672E3B";
var y;
var author;
//A callback function to generate a new quote and a color.
function changeColorQuote(){
  
 
//Using getJASON to retreive data.
  $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=40&callback=", function(result){
    //Quotes transition animation.
      $("h4").animate({
          opacity: 0
        }, 500,
        function() {
          $(this).animate({
            opacity: 1
          }, 500);
    // Cap quote text lenght to 120 characters.    
    var z = 121;
    author = result[Math.floor(Math.random()*31)].title;
    while (z > 120){
     y = result[Math.floor(Math.random()*40)].content;
     z = y.length; 
    }
    
    //Updating different properties on button click.    
    $("#text").html(y);
    $("#text").css("font-size","25px");
    $("#initialMessage").text("");
    $("#authorid").html("~ " + author + " ~");
    //$("h5").css("font-size","17px");   
    
          }); 
  });
 
    //Generate random colors
    var hexArrayGenerator = [];
    
    hexArrayGenerator.push(Math.floor(Math.random() * 10));
    hexArrayGenerator.push(Math.floor(Math.random() * 10));
    hexArrayGenerator.push(Math.floor(Math.random() * 10));
    x = "#" + hexArrayGenerator.join("");
    $("body").animate({backgroundColor: x, color: x}, 1000);
    $("#button1").animate({backgroundColor: x}, 1000);
    $("#button2").animate({backgroundColor: x}, 1000);
    $("h1").animate({color: x}, 1000);
     
};

//Tweeting the generated code.
$(document).ready(function(){
  
  $("#button2").hover(function(){
    $(this).css("background-color", x );
  });
  
  $("#button2").on("click", function(){
    var tweetArray = ['https://twitter.com/intent/tweet?text='];
    //var slicedY =(y.slice(3,(y.length - 5)));
    tweetArray.push($("#message").text());
    var tweetString = (tweetArray.join(""));
    //tweetString = tweetString.replace(/&#8217;/gi,"%27");
    tweetString = tweetString.replace(/;/gi,"%3B");
    $("#tweet").attr("href",tweetString + "%0A~ " + author + ' ~');
  })
})


//$('.twitter-share-button').attr('data-text', 'Hello!');

/*function colorSelector(){
    var hexArrayGenerator = [];
    
    hexArrayGenerator.push(Math.floor(Math.random() * 10));
    hexArrayGenerator.push(Math.floor(Math.random() * 10));
    hexArrayGenerator.push(Math.floor(Math.random() * 10));
    var x = "#" + hexArrayGenerator.join("");
  
   $("#message").css("color", x );
   
    return x;
  
  }; */

 /* //Using ajax to retreive data.
  $.ajax({url:"https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", cache: false, success: function(result){
    
    $("h4").animate({
          opacity: 0
        }, 500,
        function() {
          $(this).animate({
            opacity: 1
          }, 500);  
      
         $("h4").html("<p>" + result[0].content + "</p><br> ~ " + result[0].title + " ~");
          }); 
        
  }});  */      
              
            
!
999px

Console