A Pen by Kamal Iqlaas on CodePen.
Created
August 9, 2017 00:44
-
-
Save Iqlaas/ce8a569f8f918ed13bee4484421a3652 to your computer and use it in GitHub Desktop.
FCC - Build a quote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="box"> | |
<div class="main"> | |
<div class="quot quot-top">“</div> | |
<p></p> | |
<i class="author"></i> | |
<div class="quot quot-bottom">”</div> | |
<div id="btnbox"> | |
<button class="btn btn-primary"><i class="glyphicon glyphicon-comment" aria-hidden="true"></i> Random quote</button> | |
<a id="tweetlink" href="#" class="btn btn-info"><i class="glyphicon glyphicon-retweet" aria-hidden="true"></i> Tweet this quote</a> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var qurl = "https://api.forismatic.com/api/1.0/?format=jsonp&method=getQuote&jsonp=?&lang=en"; | |
var turl = "https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text="; | |
$("button").on("click", function() { | |
getQuote(); | |
}); | |
function getQuote() { | |
$.getJSON(qurl, function(response) { | |
$("p").html(response.quoteText); | |
$("i.author").html(response.quoteAuthor); | |
$("#tweetlink").attr("href", | |
turl + response.quoteText + " ― " + response.quoteAuthor); | |
}); | |
} | |
getQuote(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.box { | |
display: flex; | |
align-items: center; | |
height: 100vh; | |
width: 100vw; | |
justify-content: center; | |
} | |
.main { | |
max-width: 700px; | |
margin-left: 50px; | |
margin-right: 50px; | |
width: 100%; | |
padding: 30px; | |
font-size: 20px; | |
position: relative; | |
} | |
.quot { | |
font-size: 200px; | |
position: absolute; | |
z-index: -1; | |
line-height: 100px; | |
color: #ccc; | |
} | |
.quot-top { | |
top: 0; | |
left: 0; | |
} | |
.quot-bottom { | |
top: 90%; | |
right: 0; | |
} | |
#btnbox { | |
margin-top: 50px; | |
text-align: center; | |
} | |
i.author { | |
text-align:right; | |
display: block; | |
} | |
i.author::before { | |
content: "― "; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment