123

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.

            
              <div class="container">
    <div id="quoteCard" class="row quote-card">
      <div class="col s12 m6 offset-m3">
        <div class="card hoverable">
          <div class="card-content">
            <blockquote><p id="phrase">"Sometimes it is the people no one can imagine anything of, who do the things no one can imagine."</p><footer><cite id="author">- Alan Turing</cite></footer></blockquote>
            <a onClick="tweetIt()" href="https://twitter.com/intent/tweet" target="_blank"><i class="fa fa-twitter fa-lg" aria-hidden="true"></i></a>
            <a class="right" href="#" id="newQuote">New Quote</a>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="container">
    <a class="waves-effect waves-light btn blue lighten-2 hoverable" id="linkToPortfolio" href="https://njm8.github.io/" target="_blank">Created by Nate Mallison</a>
  </div>
  
            
          
!
            
              html { 
  background: url('https://github.com/NJM8/FreeCodeCampFrontEndProjects/blob/master/randomQuoteGenerator/01860_sanfrancisco_2560x1600.jpg?raw=true') no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

.quote-card {
  position: absolute;
  top: 0px;
  left: 0px;
  padding-top: 125px;
  padding-left: 200px;
  z-index: 10;
}

.card {
  width: 400px;
}

.linkToPortfolio {
  position: absolute;
  
}

@media screen and (max-width: 1024px) { 
  img {
    left: 50%;
    margin-left: -512px; 
  }
}
            
          
!
            
              function tweetIt () {
  var phrase = document.getElementById('phrase').innerText;
  var author = document.getElementById('author').innerText;
  var tweetUrl = 'https://twitter.com/intent/tweet?text=' +
  encodeURIComponent(phrase) + " " + encodeURIComponent(author);
  window.open(tweetUrl);
}

var quotes = {
  quote_0: {
    id: 0,
    phrase: "People often say that motivation doesn’t last. Well, neither does bathing. That’s why we recommend it daily.",
    author: "Zig Ziglar"
  },
  quote_1: {
    id: 1,
    phrase: "The best time to plant a tree was 20 years ago, the second best time is now.",
    author: "Chinese Proverb"
  },
  quote_2: {
    id: 2,
    phrase: "It does not matter how slowly you go as long as you do not stop.",
    author: "Confucius"
  },
  quote_3: {
    id: 3,
    phrase: "In the end, it's not the years in your life that count. It's the life in your years.",
    author: "Abraham Lincoln"
  },
  quote_4: {
    id: 4,
    phrase: "However bad life may seem, there is always something you can do, and succeed at. While there is life, there is hope.",
    author: "Stephen Hawking"
  },
  quote_5: {
    id: 5,
    phrase: "Always do right. This will gratify some people and astonish the rest. ",
    author: "Mark Twain"
  },
  quote_6: {
    id: 6,
    phrase: "Every strike brings me closer to the next home run.",
    author: "Babe Ruth"
  },
  quote_7: {
    id: 7,
    phrase: "The mind is everything. What you think you become.",
    author: "Buddha"
  },
  quote_8: {
    id: 8,
    phrase: "Your time is limited, so don’t waste it living someone else’s life.",
    author: "Steve Jobs"
  },
  quote_9: {
    id: 9,
    phrase: "You can never cross the ocean until you have the courage to lose sight of the shore.",
    author: "Christopher Columbus"
  },
  quote_10: {
    id: 10,
    phrase: "If you hear a voice within you say “you cannot paint,” then by all means paint and that voice will be silenced.",
    author: "Vincent Van Gogh"
  },
  quote_11: {
    id: 11,
    phrase: "The best way to predict the future is to create it." ,
    author: "Abraham Lincoln"
  },
  quote_12: {
    id: 12,
    phrase: "When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'Happy'. They told me I didn't understand the assignment and I told them they didn't understand life." ,
    author: "John Lennon"
  },
  quote_13: {
    id: 13,
    phrase: "If today were the last day of your life, would you want to do what you are about to do today?" ,
    author: "Steve Jobs"
  },
  quote_14: {
    id: 14,
    phrase: "Have no fear of perfection, you'll never reach it." ,
    author: "Salvador Dali"
  },
  quote_15: {
    id: 15,
    phrase: "The greatest glory in living lies not in never falling, but in rising every time we fall." ,
    author: "Nelson Mandela"
  },
  quote_16: {
    id: 16,
    phrase: "We cannot solve our problems with the same thinking used when we created them." ,
    author: "Albert Einstein"
  },
  quote_17: {
    id: 17,
    phrase: "Do not pray for an easy life, pray for the strength to endure a difficult one." ,
    author: "Bruce Lee"
  },
  quote_18: {
    id: 18,
    phrase: "If you cannot fly, then run. If you cannot run, then walk. If you cannot walk then crawl, but whatever you do, you have to keep moving forward." ,
    author: "Martin Luther King Jr."
  },
  quote_19: {
    id: 19,
    phrase: "If you truly love life, don't waste time; because time is what life is made of." ,
    author: "Bruce Lee"
  },
  quote_20: {
    id: 20,
    phrase: "However bad life may seem, there is always something you can do, and succeed at. While there is life, there is hope." ,
    author: "Stephen Hawking"
  }
}

$("#newQuote").click(function(){
  $("#quoteCard").fadeOut("slow", function(){
    showNewQuote();
  })
});

function showNewQuote(){
  var randNum = Math.floor(Math.random() * 20 + 1);
  var newQuote = "";
  var newAuthor = "";
  var newTopPadding = Math.floor(Math.random() * 600 + 1);
  var newLeftPadding = Math.floor(Math.random() * 600 + 1);
  for (var key in quotes) {
    for (var key2 in quotes[key]){
      if (quotes[key][key2] === randNum) {
        newQuote = quotes[key].phrase;
        newAuthor = quotes[key].author;
      } 
    }
  }
  $("#phrase").html(newQuote);
  $("#author").html(newAuthor);
  $("#quoteCard").css({"padding-top": newTopPadding});
  $("#quoteCard").css({"padding-left": newLeftPadding});
  $("#quoteCard").fadeIn("slow", function(){
  });
};
            
          
!
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