Skip to content

Instantly share code, notes, and snippets.

@Iqlaas
Created August 9, 2017 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Iqlaas/ce8a569f8f918ed13bee4484421a3652 to your computer and use it in GitHub Desktop.
Save Iqlaas/ce8a569f8f918ed13bee4484421a3652 to your computer and use it in GitHub Desktop.
FCC - Build a quote
<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>
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();
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
.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: "― ";
}
<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