Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <body> 
  
 <h1 class= "text-center containerTitle"> Random Quote Machine </h1> 
 <div id = "container" class= "text-center"> 
   <div id="quote"></div> 

  </div> 
  <div id="button">
  <button class = "text-center btn btn-primary" id ="newQuoteButton">New Quote</button>  
    
    <a href="#" id="tweetQuote" target="_blank"><button id = "tweetBtn" class = "btn btn-primary"><i class="fa fa-twitter">Tweet This!</i></button></a>
    
   
    
  </div> 
  
</body> 
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Lobster'); 

body { 
  background-image: url(http://res.cloudinary.com/ynd/image/upload/v1499453593/simpleBackground_g8gyzo.jpg); 
} 

.containerTitle {
  padding: 3%; 
  font-family: Lobster; 
}

#container { 
  background-color: #ffffff; 
  width: 80%;
  margin-right: auto;
  margin-left: auto;
  /*min-width: 900px;*/
	max-width: 1280px; 
  padding: 3%; 
  margin-top: 2%; 
  /*box-shadow: 3px 3px 3px 3px black; */ 
} 

#quote {
  font-size: 20pt; 
} 

#newQuoteButton {
  margin-top: 3%; 
  margin-bottom: 3%; 
  padding: 10px; 
  background-color: #ffffff; 
  color: black; 
  box-shadow: 1px 1px 1px 1px black; 
}

#button {
  text-align: center; 
} 

#tweetBtn {
  color: #000000; 
  margin-top: 3%; 
  margin-bottom: 3%; 
  margin-left: 5%; 
  padding: 10px; 
  background-color: #ffffff; 
  box-shadow: 1px 1px 1px 1px black; 
} 

 

            
          
!
            
              var randQuote;  
var quoteArr = ["&quotThe best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart.&quot<small> - Helen Keller</small>", "&quotHappiness is not something you postpone for the future; it is something you design for the present.&quot<small> - Jim Rohn</small>", "&quotBelieve you can and you are halfway there.&quot<small> - Theodore Roosevelt</small>", "&quotIf you want to know what a man's like, take a good look at how he treats his inferiors, not his equals.&quot<small> - J.K Rowling</small>", "&quotIt is our choices...that show what we truly are, far more than our abilities.&quot<small> - J.K Rowling</small>", "&quotFloat like a butterfly, sting like a bee.&quot<small> - Muhammad Ali</small>" ,"&quotWe do not need magic to transform our world. We carry all of the power we need inside ourselves already.&quot<small> - J.K Rowling</small>", "&quotDon't count the days, make the days count.&quot<small> - Muhammad Ali</small>", "&quotHe who is not courageous enough to take risks will accomplish nothing in life.&quot<small> - Muhammad Ali</small>", "&quotYou don't choose your family. They are God's gift to you as you are to them.&quot<small> - Desmond Tutu</small>", "&quotWhen you look at your life, the greatest happiness is family happiness.&quot<small> - Unknown</small>"]; 

function displayQuote() {
  var randomIndex = Math.floor(Math.random() * quoteArr.length); 

  var randomQuote = quoteArr[randomIndex]; 
  
  document.getElementById('quote').innerHTML = randomQuote; 

  randQuote = randomQuote.replace(/<small>|&quot|;|<\/small>/g, ""); 
    
  document.getElementById("tweetQuote").setAttribute("href", "https://twitter.com/intent/tweet?text="+encodeURIComponent(randQuote)); 
} 

displayQuote(); 

$(document).ready(function() {
  $('#newQuoteButton').on('click', function() {
    
     displayQuote(); 
    
  });
  
}); 


            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console