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="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>
            
          
!
            
              .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;
}
            
          
!
            
              // 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
🕑 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