Hey friends,

Do check out my YouTube channel to watch this tutorial and do subscribe to support me! Thanks!


<!-- Created by CodingPorium,2021. Visit https://youtube.com/c/CodingPorium for more tutorials with free source code -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Programming Quotes Generator using JavaScript | CodingPorium</title>
</head>
<style>
 @import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');

*{
  padding:0;
  margin:0;
  box-sizing:border-box;
}

::selection{
  background-color: #4208c9;
  color:white;
}

body{
  background-color: #4208c9;
  color:black;
  display:flex;
  justify-content: center;
  align-items: center;
  height:100vh;
  font-family: poppins;
  font-size:10px;
}

.container{
  width:90%;
  max-width:500px;
  margin:0 auto;
  background-color: white;
  border-radius: 8px;
  padding:3rem;
  display:flex;
  flex-direction: column;
}

.container p{
  font-size:2rem;
  font-weight:300;
  line-height:3rem;
  text-align:justify;
}

button{
  margin-top:40px;
  width:fit-content;
  padding:2rem;
  font-size:2rem;
  font-family: poppins;
  background-color: #4208c9;
  color:white;
  border:none;
  border-radius:5px;
  cursor:pointer;
  align-self:flex-end;
  transition:0.3s;
  outline:none
}

button:hover{
  opacity:0.7;
}
</style>
<body>
<div class="container">
  <p id="quote"></p>
  <p id="author" class="author"></p>
  <button onclick="getQuote()">Get a Quote!</button>
</div>
</body>
<script>
const Quote = document.getElementById("quote");
const Author = document.getElementById("author");
function getQuote(){
  fetch("http://quotes.stormconsultancy.co.uk/random.json")
  .then((res) => {
    return res.json();
  })
  .then((data) => {
    Quote.innerText = data.quote;
    Author.innerText = `-${data.author}`;
  });
}

getQuote()



</script>
</html>

Post a Comment

Previous Post Next Post