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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Random Quote Machine</title>
    <link rel="stylesheet" type="text/css" href="https://netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css">
    <link href="https://fonts.googleapis.com/css?family=Indie+Flower" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
    <main class="content">
        <div class="quote">
            <h3 id="quote-content">It's all about quality of life and finding a happy balance between work and friends and family</h3>
            <p id="quote-title">- Philip Green</p>
        </div>
        <footer>
        <button type="button" class="quotebtn">Next Quote</button>
        <a class="icon-button twitter" ><i class="icon-twitter"></i></a>
        </footer>
    </main>
    
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
   <script src="index.js"></script>
              

</body>

</html>
              
            
!

CSS

              
                body {
    background: url("https://images.unsplash.com/photo-1486180939859-b2fe47b8037d?auto=format&fit=crop&w=1952&q=60&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D") no-repeat center center fixed;
}

.content {
    width: 600px;
    text-align: center;
    height: auto;
    margin: auto; 
    margin-top:200px;
}

footer{
  position: relative;
  width:200px;
  height:auto;
  margin:0 auto;
}
.quote{
    font-size:20px;
    font-family:"Indie Flower",cursive;
    color:#FDFCFCFF;
    margin-top:30px;
}

.quotebtn {
  background: #c034d9;
  background-image: -webkit-linear-gradient(top, #c034d9, #2980b9);
  background-image: -moz-linear-gradient(top, #c034d9, #2980b9);
  background-image: -ms-linear-gradient(top, #c034d9, #2980b9);
  background-image: -o-linear-gradient(top, #c034d9, #2980b9);
  background-image: linear-gradient(to bottom, #c034d9, #2980b9);
  -webkit-border-radius: 28;
  -moz-border-radius: 28;
  border-radius: 28px;
  text-shadow: 1px 1px 3px #666666;
  font-family: Georgia;
  color: #ffffff;
  font-size: 20px;
  padding: 10px 20px 10px 20px;
  text-decoration: none;
  display: inline-block;
  vertical-align: middle;
  float:left;
}

.quotebtn:hover {
  background: #fc3c7f;
  background-image: -webkit-linear-gradient(top, #fc3c7f, #d9a734);
  background-image: -moz-linear-gradient(top, #fc3c7f, #d9a734);
  background-image: -ms-linear-gradient(top, #fc3c7f, #d9a734);
  background-image: -o-linear-gradient(top, #fc3c7f, #d9a734);
  background-image: linear-gradient(to bottom, #fc3c7f, #d9a734);
  text-decoration: none;
}
.icon-button {
    background-color: white;
    border-radius: 3.6rem;
    cursor: pointer;
    display: inline-block;
    font-size: 2.0rem;
    height: 3.6rem;
    line-height: 3.6rem;
    margin: 0 5px;
    position: absolute;
    text-align: center;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    width: 3.6rem;
    display: inline-block;
    vertical-align: middle;
    float:right;
}


/* Circle */

.icon-button span {
    border-radius: 0;
    display: block;
    height: 0;
    left: 50%;
    margin: 0;
    top: 50%;
  position:absolute;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    -o-transition: all 0.3s;
    transition: all 0.3s;
    width: 0;
  
}

.icon-button:hover span {
    width: 3.6rem;
    height: 3.6rem;
    border-radius: 3.6rem;
    margin: -1.8rem;
}

.icon-twitter {
    background: #4099ff;
}

/* Icons */

.icon-button i {
    background: none;
    color: white;
    height: 3.6rem;
    left: 0;
    line-height: 3.6rem;
    position: absolute;
    top: 0;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    -o-transition: all 0.3s;
    transition: all 0.3s;
    width: 3.6rem;
    z-index: 10;
  float:right;
}

.icon-button .icon-twitter {
    color: #4099ff;
}

.icon-button:hover .icon-twitter{
    color: white;
    background: #4099ff;
    border-radius: 50%
}
              
            
!

JS

              
                $(document).ready(function(){
		var quote='';
		var author='';
		function getQuote(){	
    $.ajax({
      url:"https://api.forismatic.com/api/1.0/",
      jsonp: "jsonp",
      dataType: "jsonp",
      data: {
        method: "getQuote",
        lang: "en",
        format: "jsonp"
      },
      success: function(post) {
      	quote = post.quoteText;
      	author = post.quoteAuthor;

        // If the Source is available, use it. Otherwise hide it.
        if (author = post.quoteAuthor){
        $('#quote-content').html(post.quoteText);
        $('#quote-title').text(post.quoteAuthor);
        } else {
        $('#quote-content').html(quote);
        $('#quote-title').text("Unkown");
        }
    },
     
      cache: false
    });
};

    $('.quotebtn').on('click', function(event){
    	event.preventDefault();
    	getQuote();
    });


    $('.twitter').on('click', function (){
    	$(this).attr('href','https://twitter.com/intent/tweet?text='+quote+" -"+author);
       });
});

              
            
!
999px

Console