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.

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

              
                <body>
  <div class="container-fluid">
   <h1>Random Quote Machine</h1>
  <div class="container container-fluid">
    <p id="changeQuote" class="center"></p>
    <div id="center">
    <div class="row">
    <div class="col-sm-4">
    <button class="btn btn-primary" onclick="newQuote()">New Quote</button>
    </div>
    <div class="col-sm-4">
      <a href="https://twitter.com/intent/tweet"><button class="btn btn-primary" onclick="tweetQuote()" target="_blank" id="tweet">Tweet a Quote</button></a>
    </div>
    </div>
    </div>
  </div>
  </div>
</body>
              
            
!

CSS

              
                h1 {
  text-align: center;
  margin-top: 20px;
  color: navy;
}

body {
  background-color: black;
}

p {
  color: white;
  text-align: center;
  margin-top: 30px;
}

div#center {
  text-align: center;
  margin-left: 370px;
}

.center {
  text-align: center;
}
              
            
!

JS

              
                var myQuotes = ["The Way Get Started Is To Quit Talking And Begin Doing. -Walt Disney",
                "The Pessimist Sees Difficulty In Every Opportunity. The Optimist Sees The Opportunity In Every Difficulty. -Winston Churchill",
                "Don\'t Let Yesterday Take Up Too Much Of Today. -Will Rogers",
                "You Learn More From Failure Than From Success. Don\'t Let It Stop You. Failure Builds Character. -Unknown",
                "It\'s Not Whether You Get Knocked Down, It\'s Whether You Get Up. -Vince Lombardi",
                "If You Are Working On Something That You Really Care About, You Don\'t Have To Be Pushed. The Vision Pulls You. -Steve Jobs",
                "People Who Are Crazy Enough To Think They Can Change The World, Are The Ones Who Do. -Rob Siltanen",
                "Failure Will Never Overtake Me If My Determination To Succeed Is Strong Enough. -Og Mandino",
                "Entrepreneurs Are Great At Dealing With Uncertainty And Also Very Good At Minimizing Risk. That\'s The Classic Entrepreneur. -Mohnish Pabrai",
                "We May Encounter Many Defeats But We Must Not Be Defeated. -Maya Angelou"
]

var userQuote;

function newQuote() {
    var randomNumber = Math.floor 
    (Math.random() * (myQuotes.length));
    document.getElementById("changeQuote").innerHTML = myQuotes[randomNumber];
  tweetQuote(randomNumber)
}

function tweetQuote(randomNumber) {
var tweet = myQuotes[randomNumber];
document.getElementById("tweet").href = 'https://twitter.com/share?text=' +
encodeURIComponent(tweet);
}
              
            
!
999px

Console