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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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">
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Random Quote Machine</title>
  <!-- Styles -->
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/font-awesome.min.css" rel="stylesheet">
  <link href="css/style.min.css" rel="stylesheet">
</head>

<body>

  <div class="container">
    <h1>Random Quote Machine</h1>
    <p>These are some of my favorite quotes from my many years of reading, writing, and tv watching. Enjoy!</p>

    <button class="btn btn-new-quote">New Quote</button>

    <blockquote class="quote">
      <h2 id="quote" class="new-quote"></h2>
      <small id="attribution" class="author"></small>
    </blockquote>

    <a target="_blank" href="#" id="tweet-button"><i style="color: black;" class="fa fa-twitter fa-3x" aria-hidden="true"></i></a>

  </div>

  <script src="js/jquery-3.1.1.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script src="js/script.js"></script>
</body>
</html>

              
            
!

CSS

              
                @font-face {
  font-family: "Bubbler One";
  src: url(../fonts/BubblerOne-Regular.ttf);
}

body {
  width: 100%;
  height: 100%;
  background-color: firebrick;
  -moz-box-shadow:    inset 0 0 40px #000000;
  -webkit-box-shadow: inset 0 0 40px #000000;
  box-shadow:         inset 0 0 40px #000000;
}

.container {
  background-color: peru;
  padding-top: 150px;
  padding-left: 20px;
  padding-right: 20px;
  text-align: center;
  height: 100vh;
  border: 2px solid black;
  border-radius: 50%;
}

h1 {
  color: firebrick;
  font-family: "Brush Script MT", cursive;
  font-weight: bold;
  font-size: 64px;
  text-shadow: 2px 2px 2px #000;
}

p {
  font-family: "Bubbler One";
  color: firebrick;
  font-size: 32px;
  font-weight: bold;
}

.btn-new-quote {
  font-weight: bold;
  font-size: 24px;
  color: goldenrod;
  background-color: firebrick;
  border: 4px;
  box-shadow: 3px 3px 3px #000;
  &:hover {
    background-color: maroon;
    color: goldenrod;
  }
}

blockquote {
  font-family: Brush Script MT, cursive;
  margin-left: 15%;
  margin-top: 3%;
  width: 70%;
  box-shadow: 2px;
  border: 0;
  .new-quote {
    font-size: 40px;
    color: firebrick;
    font-weight: bold;
  }
  .author {
    color: firebrick;
    font-size: 40px;
    font-weight: bold;
  }
}

              
            
!

JS

              
                $(document).ready(function() {
  // On page load, calls function to pick first quote and use that quote for tweet
  changeQuote();
  setUpTweet();

  // Calls function for changing quote whenever "new quote" button is pressed
  $(".btn-new-quote").on("click", function() {
    changeQuote();
    setUpTweet();
  });



  // $(".btn-new-quote").click(function() {
  //   var textToTweet = $(".quote>h2").text();
  //   console.log(textToTweet);
  //   $("blockquote a").attr("href", "https://twitter.com/intent/tweet?original_referer=http%3A%2F%2F127.0.0.1%3A8000%2F&ref_src=twsrc%5Etfw&text=" + "textToTweet + &tw_p=tweetbutton&url=http%3A%2F%2F127.0.0.1%3A8000%2F");
  //   console.log("Test");
  // });
});

function setUpTweet() {
  var quote = $("#quote").text();
  var attributedTo = $("#attribution").text();
  var tweetURL = "https://twitter.com/intent/tweet?text=" + '"' + quote + '" - ' + attributedTo + "@alan1649";
  $("#tweet-button").attr("href", tweetURL);
}

// Functionality for new-quote button as well as cases for all possible quotes
function changeQuote() {
  var quote = "";
  var attributedTo = "";
  var randomValue = Math.floor((Math.random() * 10) + 1);
  switch(randomValue)
    {
      case 1:
        quote = "It is never too late to be what you might have been.";
        attributedTo = "George Eliot";
        break;
      case 2:
        quote = "The man who does not read has no advantage over the man who cannot read.";
        attributedTo = "Mark Twain";
        break;
      case 3:
        quote = "In three words I can sum up everything I have learned about life: it goes on.";
        attributedTo = "Robert Frost";
        break;
      case 4:
        quote = "Live as if you were to die tomorow. Learn as if you were to live forever.";
        attributedTo = "Mahatma Ghandi";
        break;
      case 5:
        quote = "Fairytales are more than true: not because they tell us that dragons exist, but because they tell us that dragons can be beaten.";
        attributedTo = "Neil Gaiman";
        break;
      case 6:
        quote = "We don't see things as they are, we see them as we are.";
        attributedTo = "Anaïs Nin";
        break;
      case 7:
        quote = "Life is like riding a bicycle. To keep your balance, you must keep moving.";
        attributedTo = "Albert Einstein";
        break;
      case 8:
        quote = "Life isn't about finding yourself. Life is about creating yourself.";
        attributedTo = "George Bernard Shaw";
        break;
      case 9:
        quote = "Everybody is a genius. But if you judge a fish by its ability to climb a tree it will go its whole life believing it is stupid.";
        attributedTo = "Anonymous";
        break;
      case 10:
        quote = "Be the change that you wish to see in the world.";
        attributedTo = "Mahatma Ghandi";
      }
  $("#quote").html(quote);
  $("#attribution").html(attributedTo);
}

              
            
!
999px

Console