Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div class="wrap">
  <div class="container">
    <div class="row">
      <div class="col-12-lg title">
        <h1 class="center-block"> Random Quote Generator </h1>
        <br>
        <h2 class="center-block"> A selection of quotes related to soccer/football </h2>
        <br>
      </div>
    </div>
    <div class="jumbotron" id="jumbotron">
      <p id="quote"> Press new quote to display a random quote. Press tweet to tweet the quote! </p>
      <p><small id="authorDate"> - Anthony Bruno, 2015 </small> </p>
    </div>
  </div>
  <div class="container center-block" id="buttons">
    <button class="btn btn-default" id="newQuote"> New Quote </button>
    <button class="btn btn-default" href="https://twitter.com/intent/tweet" id="tweet"> <i class="fa fa-twitter"></i> Tweet </button>
  </div>
</div>
              
            
!

CSS

              
                .wrap{
  background: url('http://seasonssoccerclub.org/wp-content/uploads/2015/12/o-SOCCER-facebook.jpg') no-repeat center center;
height:100vh;
}

.title {
  padding-top: 10vh;
  padding-bottom: 10vh;
}
#authorDate {
  float: right;
}

#quote {

}

.jumbotron{
  min-height: 175px; 
  box-shadow: 10px 10px 2px #000000;
}

.center-block {
  margin: 0 auto;
  float: none;
  text-align: center;
}

h1{
  font-weight: bold;
  color: white;
    text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;  
}

h2 {
    color: white;
    text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;  
}

.fa-twitter {
  color: #55acee
}
              
            
!

JS

              
                /* --- Global variables for HTML elements  --- */
var newQuoteBtn = document.getElementById("newQuote");
var tweetBtn = document.getElementById("tweet");
var quote = document.getElementById("quote");
var authorDate = document.getElementById("authorDate");
/* ---       End of Global Variables      --- */

/* --- Adding Event Listeners to buttons --- */
if (newQuoteBtn.addEventListener) {
  newQuoteBtn.addEventListener("click", generateQuote, false);
} else if (newQuoteBtn.attachEvent) {
  newQuoteBtn.attachEvent('on click', generateQuote);
}
if (tweetBtn.addEventListener) {
  tweetBtn.addEventListener("click", tweetQuote, false);
} else if (tweetBtn.attachEvent) {
  tweetBtnattachEvent('on click', tweetQuote);
}
/* ---                                   --- */

/* Global Variable(s) */
var lastNumber = -1;
/*--------------------*/

/* Gets a quote and displays it */
function generateQuote() {
  var line = getQuote();
  line = line.split("|");
  quote.innerHTML = line[0];
  authorDate.innerHTML = " - "+line[1];
}


/* Returns random quote from quoteArray */
function getQuote() {
  var quoteArray = ["When I meet a European, the first thing I say is, “I’d much rather watch football than football.” But I’m just teasing them, and they know I’d really rather watch football than football.|Jarod Kintz","Many people say I'm the best women's soccer player in the world. I don't think so. And because of that, someday I just might be.|Mia Hamm","A penalty is a cowardly way to score.|Pelé","Football is a team sport and not an individual sport. We win as a team, and every individual is better if we are part of the team.|Fernando Torres","What I do is play soccer, which is what I like.|Lionel Messi","Football (soccer) is a matter of life and death, except more important.|Bill Shankly","Football is the ballet of the masses|Dmitri Shostakovich","International football is the continuation of war by other means|Eric Arthur Blair"];

do {
var randomNumber = Math.floor(Math.random() * quoteArray.length);
} while(randomNumber === lastNumber);
  
lastNumber = randomNumber;
return quoteArray[randomNumber];
}

/* opens a new window with the quote as a tweet */
function tweetQuote() {
  var quoteText = quote.innerHTML;
  window.open("https://twitter.com/intent/tweet?text="+quoteText+"&related=AnthonyBrunoAUS");
}


              
            
!
999px

Console