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="myContainer">
  
<!-- Centered heading -->
  <div class="container-fluid">
    <div class="row text-center">
      <div class="col-md-3  col-sm-2 col-xs-0"></div>
      <div class="col-md-6  col-sm-8 col-xs-12">
        <h1 class="text-center">Random Travel Quotes</h1>
      </div>
      <div class="col-md-3  col-sm-2 col-xs-0"></div>
    </div>
  </div>
  
  <!-- Botones -->
  
  <div class="container-fluid">
    <div class="row">
      <div class="col-lg-5 col-md-5 col-sm-4 col-xs-2"></div>
      <div class="col-lg-2 col-md-2 col-sm-4 col-xs-8 text-center">
        <button type="button" class="btn btn-success" id="newQuote" onclick="generate()">Give me more inspiration!</button>
      </div>
      <div class=" col-lg-5 col-md-5 col-sm-4 col-xs-2"></div>
    </div>
  </div>
  
  <!-- Quote screen -->
  
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-3 col-sm-2 col-xs-0"></div>
      <div class="col-md-6 col-sm-8 col-xs-12">
        <div class="screen">
          <div id="cita">"Find your favourite travel quote right here!"
          </div>
          <div class="text-right" id="autor">- Random Travel Quotes
          </div>
          <div id="share">
            <a class="twitter-share-button"
               id="shareQuote"
               onclick="share()"
               href="https://twitter.com/intent/tweet?text=" data-size="default">
            </a>
          </div>
        </div>
      </div>
      <div class="col-md-3 col-sm-2 col-xs-0"></div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                .myContainer {
  background-image: url("http://www.storychick.com/wp-content/uploads/2015/07/o-road-trip-facebook.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position:center;
  position: absolute;
  width: 100%;
}

h1 {
  font-family: 'Fredericka the Great', cursive;
  color: #EAEAEA;
  font-size: 420%;
  margin: 10% auto 10px auto;
  display: block;
}

.screen{
  position: relative;
  background-color: #ffffff;
  opacity: 0.5;
  height: auto;
  border-radius: 25px;
  margin-top: 280px;
  bottom: 50px;
}

.btn {
  margin-top: 25px;
}

.screen{
  padding: 20px 40px 10px 40px;
  font-family: 'Corben', cursive;
  font-size: 1.2em;
}

#autor {
  font-weight: bold;
  font-size: 1.1em;
}

a {
  z-index: 10;
}
              
            
!

JS

              
                // Array with the quotes and the authors

var quotes = [
  ["Not all those who wander are lost.", "J. R. R. Tolkien"],
  ["The journey of a thousand miles begins with a single step.", "Lao Tzu"],
  ["A journey is like marriage. The certain way to be wrong is to think you control it.", "J. Steinbeck"],
  ["Your true traveler finds boredom rather agreeable than painful. It is the symbol of his liberty — his excessive freedom. He accepts his boredom, when it comes, not merely philosophically, but almost with pleasure.", "Aldous Huxley"],
  ["I travel not to go anywhere, but to go. I travel for travel's sake. The great affair is to move.", "R. L. Stevenson"],
  ["Travel makes one modest. You see what a tiny place you occupy in the world.", "G. Flaubert"],
  ["It is not down in any map; true places never are.", "H. Melville"]
];

/* Variables for the random number (rand)
   the quote (cita)
   and the author (autor) */

var rand;
var cita;
var autor;
var twitterURL = "https://twitter.com/intent/tweet?text=";

/* This function generates a random number and saves the random quote and author in global variables cita and author */

function generate() {
  rand = Math.floor(Math.random() * quotes.length);
  cita = document.getElementById("cita").innerHTML = "\"" + this.quotes[rand][0] + "\"";
  autor = document.getElementById("autor").innerHTML = "- " + this.quotes[rand][1];
  alert(encodeURIComponent(this.quotes[rand][0]));
  alert(encodeURIComponent(this.quotes[rand][1]));
 
  
}

/* This function generates the Twitter URL to share including the quote and the author */

function share() {
  twitterURL += encodeURIComponent(this.quotes[rand][0]) + " – " + encodeURIComponent(this.quotes[rand][1]);
  document.getElementById("shareQuote").href = twitterURL;
  alert(twitterURL);
}

$(document).ready(function() {

  $("#shareQuote").click(function() {
    twitterURL += encodeURIComponent(cita) + " – " + encodeURIComponent(autor);
    document.getElementById("shareQuote").href = twitterURL;
    alert(twitterURL);
  });
});
              
            
!
999px

Console