css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              

<h1>Welcome to the random quote machine</h1>
<div class ="quote">
  <p id ="para">Welcome to the random quote machine</p>
  <button type="button" id="tweet" class=" btn btn-primary btn-lg" title="tweet this"><i class="fa fa-twitter"></i> tweet</button>

</div>
<button class = "btn btn-success btn-lg"id="but">quote</button>

            
          
!
            
              html,body{
  margin:0;

}
#but{
  background:red;
}
.quote{
  background:violet;
  padding:4%;
  margin: auto ;
  width :90%;
  height:90%;
  text-align:center;
  border : 10px solid blue;
}
.quote p{
  background:white;
  font-size:30px;
  text-align:center;
}
button{
  margin-top:0;
  margin-left:45%;
  height:40px;
}
h1{
  text-align:center;
  background:skyblue;
  margin:auto;
}
body{
  background:#32CD32;
}
            
          
!
            
              quotes = [
  ['I love you the more in that I believe you had liked me for my own sake and for nothing else. - John Keats '],
  ['You cannot shake hands with a clenched fist. - Indira Gandhi '],
  ['It is better to be feared than loved, if you cannot be both. -  Niccolo Machiavelli '],
  ['Do not mind anything that anyone tells you about anyone else. Judge everyone and everything for yourself. - Henry James '],
  ['Learning never exhausts the mind. - Leonardo da Vinci '],
  ['There is no charm equal to tenderness of heart. - Jane Austen '],
  ['All that we see or seem is but a dream within a dream.  - Edgar Allan Poe '],
  ['The only journey is the one within. -  Rainer Maria Rilke ']
];
var tweet = document.querySelector("#tweet");
var but = document.querySelector("#but");
var para = document.querySelector("#para");
but.addEventListener('click',get_quote);
tweet.addEventListener('click',put_tweet);
var save ='Welcome to the random quote machine';
function get_quote(){
  var random = Math.floor(Math.random()*8)
   save =quotes[random];
 para.textContent = save;
}
function put_tweet()
{
  window.open('https://twitter.com/intent/tweet?&related=&text='+save);
}
            
          
!
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.
Loading ..................

Console