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.

            
              <html>
<head>
	<title>Random Quote Generator</title>
</head>
<body>
	<div class="quoteBox">
		<div class="quoteText">
			<i class="fa fa-quote-left fa-3x" id="leftQuote"></i><span id="quote">Click the button for your quote!</span>
		</div><!--close quoteText-->
		<div class="quoteAuthor">
			<span id="author">- Me</span>
		</div><!--close author-->
		<div class="buttons">
      <!--Tweet Button-->
			<a href="#" id="tweetQuote" target="_blank" title="Tweet your quote!"><i class="fa fa-twitter-square fa-4x"></i></a> 
      <!--Tumblr Button-->
      <a href="#" id="tumbleQuote" target="_blank" title="Tumble this quote!"><i class="fa fa-tumblr-square fa-4x"></i></a>
      <!--New Quote Button-->
      <button onclick="randomQuote();randomColor()" id="quoteButton">New Quote</button>
		</div><!--close buttons-->
	</div><!--close quote box>-->
</body>
</html>
            
          
!
            
              body {
  background-color: #000000;
}
.quoteBox {
  border-radius:3px;
  position:relative;
  margin:8% auto auto auto;
  width:450px;
  padding:40px 50px;
  display:table;
  background-color:#fff;;
}

#quote {
  font-size: 24px;
  margin-left: 10px;
}

#author {
  margin-left: 70%;
  font-size: 12px;
}

#tweetQuote {
  float: left;
  margin-top: 40px;
}

#tumbleQuote {
  float: left;
  margin-top: 40px;
  margin-left: 2px;
}

#quoteButton {
  float: right;
  margin-top: 50px;
  border: none;
  color: white;
  padding: 5px 5px 5px 5px;
  outline: none;
  height: 30px;
  width: 80px;
  border-radius: 4px;
}

            
          
!
            
              var quoteArray = [
    ["Because, because I’m not giving up! I’m still here and I’m staying!", "- Kermit the Frog"],
    ["I base most of my fashion taste on what doesn't itch.", "- Gilda Radner"],
    ["Bad days happen to everyone, but when one happens to you, just keep doing your best and never let a bad day make you feel bad about yourself.", "- Big Bird"],
    ["There is no normal life that is free of pain. It's the very wrestling with our problems that can be the impetus for our growth.", "- Mr. Rogers"],
    ["I don't care what they say about me. I just want to eat.", "- Pam Beesly"],
    ["I'm exceedingly smart. I graduated college at fourteen. While my brother was getting an STD, I was getting a Ph.D. Penicillin can't take this away.", "- Sheldon Cooper"],
    ["You wanna hurt me? Go right ahead if it makes you feel any better. I'm an easy target. Yeah, you're right, I talk too much. I also listen too much. I could be a cold-hearted cynic like you... but I don't like to hurt people's feelings. Well, you think what you want about me; I'm not changing. I like... I like me.", "- Del Griffith"],
    ["The point is, how do you know the Guarantee Fairy isn't a crazy glue sniffer?", "- Tommy Callihan"]
  ];

var newQuote, newAuthor;

function randomQuote() {
  var randQuote = Math.floor(Math.random() * quoteArray.length);
  newQuote = document.getElementById("quote").innerHTML=quoteArray[randQuote][0];
  newAuthor = document.getElementById("author").innerHTML=quoteArray[randQuote][1];
}

function randomColor() {
  var randColor = '#' + Math.floor(Math.random() * 0xFFFFFF).toString(16);
  document.body.style.background = randColor;
  document.getElementById("leftQuote").style.color = randColor;
  document.getElementById("author").style.color = randColor;
  document.getElementById("quote").style.color = randColor;
  document.getElementById("tweetQuote").style.color = randColor;
  document.getElementById("tumbleQuote").style.color = randColor;
  document.getElementById("quoteButton").style.background = randColor;
}

$(document).ready(function() {
  randomQuote();
  randomColor();
})

function openURL(url){
  window.open(url, 'Share', 'width=550, height=400, toolbar=0, scrollbars=1 ,location=0 ,statusbar=0,menubar=0, resizable=0');
}
                  
  $("#tweetQuote").on('click', function() {
    openURL('https://twitter.com/intent/tweet?text=' + '"' + encodeURIComponent( newQuote + '" ' + newAuthor));
  });
  
  
  /* This is the link that's not working. Using documentation from Tumblr documentation https://www.tumblr.com/docs/en/share_button but not sure how to use the data attributes*/
   
  $('#tumblr-quote').on('click', function() {
   openURL('https://www.tumblr.com/share' + '" ' + encodeURIComponent( newQuote + '"' + newAuthor )); 
  });

            
          
!
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