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.

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

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.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                <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>
  
              
            
!

CSS

              
                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; 
  }
}
              
            
!

JS

              
                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
Save your sass for CSS. Everywhere else be kind.

Console