HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Random Quote Generator </title>
<!-- google fonts -->
<link href="https://fonts.googleapis.com/css?family=Cormorant+Upright|Josefin+Slab|Raleway" rel="stylesheet">
<!-- font awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- main css file -->
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<!-- main section -->
<section class="main">
<!-- quote section -->
<section class="quote-container">
<!-- title -->
<h1 class="title">Random || Quote || Generator</h1>
<!-- end title -->
<div class="quote">
<p class="quote-text">
<span class="fa fa-quote-left fa-4x" aria-hidden="true"></span>
<span id="quote-text">Best not make any more threats to your
website. It will be met with fire and fury like the world has never seen. I will write some great placeholder
text – and nobody writes better placeholder text than me, believe me – and I’ll write it very inexpensively.
I will write some great, great text on your website’s Southern border, and I will make Google pay for
that text. Mark my words. You could see there was text coming out of her eyes, text coming out of her
wherever.</span>
<span class="fa fa-quote-right fa-4x" aria-hidden="true"></span>
</p>
<p class="quote-author">- <span id="quote-author">Knuth Rockne All American</span></p>
</div>
<!--quote button section -->
<div class="quote-button-container">
<!-- twitter share button-->
<a href="#" class="button" target="_blank" id="twitter"> <span class="fa fa-twitter-square fa-2x" aria-hidden="true"></span></a>
<!-- twitter button end -->
<!-- Facebook share button -->
<!-- <a href="#" class="button" target="_blank" id="facebook"><span class="fa fa-facebook-square fa-2x" aria-hidden="true"></span></a> -->
<!-- end Facebook share button -->
<input type="button" class="button button-quote" id="quote-button" value="New Quote">
</div>
<!-- quote button end -->
</section>
<!-- end quote section -->
<!-- author -->
<div class="made">
Made by : <a href="https://leamsigc.github.io" target="_blank">Ismael Garcia</a>
</div>
</section>
<!-- end main section -->
<!-- main js file -->
<!-- <script src="js/main.js"></script> -->
</body>
</html>
// +++++++++++++++general css =================
// font-family: 'Cormorant Upright', serif;
// font-family: 'Josefin Slab', serif;
// font-family: 'Raleway', sans-serif;
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
text-align: center;
font-size: 16px;
font-family: 'Raleway', sans-serif;
color: rgb(183, 215, 217); // background: url();
// background:linear-gradient(45deg , rgba(rgba(12, 160, 169, 0.37), 0.3) , rgba(7, 179, 153, 0.90)50%,rgba(97, 11, 90, 0.79)90%);
background: #606c88;
/* fallback for old browsers */
background: -webkit-linear-gradient(to bottom, #3f4c6b, #606c88);
/* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to bottom, #3f4c6b, #606c88);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
background-repeat: no-repeat;
}
p {
line-height: 150%;
}
a {
text-decoration: none;
color: #f7f7f7;
}
// ---------------General css end -------------
// ======main css=========
.main {
background: rgba(#000, 0.3);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
// ========qoute container css========
.quote-container {
max-width: 800px;
width: 100%;
display: flex;
justify-content: space-around;
flex-direction: column;
padding: 20px;
background: rgba(#000, 0.3);
border-radius: 5px;
box-shadow: 5px 2px 11px 1px rgba(36, 37, 41, 0.57);
}
// =====title css=======
.title {
width: 100%;
font-size: 2.5em;
font-family: 'Josefin Slab', serif;
padding: 20px;
margin-bottom: 80px;
}
.quote-text {
transition: all 0.5s ease;
padding: 10px;
margin-top: 20px;
margin-bottom: 20px;
display: flex;
justify-content: space-around;
p{
flex: auto;
}
.fa {
padding: 5px;
}
.fa-quote-left {
margin-top: -30px;
}
}
.quote-text .fa-quote-right {
align-self: flex-end;
margin-bottom: -30px;
}
// ======quote author =====
.quote-author {
transition: all 0.5s ease;
text-align: right;
padding: 20px;
font-family: 'Cormorant Upright', serif;
}
// ======== quote-button-container ============
.quote-button-container {
padding: 10px;
display: flex;
width: 100%;
transition: all 0.5s ease;
.button {
padding: 10px 15px;
border: 1px solid rgba(#000, 0.3);
margin: 10px;
color: rgba(5, 160, 242, 0.59);
background: rgba(255, 255, 255, 0.12);
border-radius: 5px;
transition: all .3s ease;
flex-basis: 50px;
&:hover {
background: rgba(#000, 0.3);
color: rgba(5, 160, 242, 0.59);
}
}
.button-quote {
margin-left: auto;
flex-basis: 300px;
font-size: 1.5em;
font-family: 'Cormorant Upright', serif;
&:hover {
color: #f2f2f2;
}
}
}
.made{
font-family: 'Cormorant Upright', serif;
}
// media querys
@media (max-width:799px) {
body {
font-size: 13px;
}
}
@media (max-width:500px) {
body {
font-size: 10px;
}
.quote-container {
padding: 5px;
}
.title {
margin: 10px 0;
}
.quote-button-container {
flex-wrap: wrap;
.button {
flex-basis: 20%;
margin: 2px;
}
.button-quote {
flex-basis: 40%;
margin-left: auto;
}
}
}
//window load and run the js
window.addEventListener('load',() => {
//quote button ;
const btnQ = document.getElementById("quote-button");
//add event listener to the btn-quote ;
btnQ.addEventListener('click', randomQuote);//click and call the random quote function ;
// random quote function ;
function randomQuote () {
const hastags = 'freecodecamp#leamsigc#quoteGenerator'
const textQuote = document.getElementById('quote-text');//text quote ;
//quote autor ;
const quoteAutor = document.getElementById('quote-author');
//twitter share button ;
const twitter = document.getElementById('twitter');
//facebook share button ;
// const facebook = document.getElementById('facebook');
//get quote api ;
let url="https://talaikis.com/api/quotes/random/";//url api;
//https://talaikis.com/random_quotes_api/ quote api ..;
fetch(url)
.then( response => {
return response.json();//convert the response to json data ;
})
.then(data => {
console.log(data);//console log the data ;
textQuote.textContent=data["quote"];//data quote to text quote ;
quoteAutor.textContent=data["author"];//quote author ;
//set attribute for share twitter
twitter.setAttribute('href' , `https://twitter.com/home/?status=${data['quote']}(${data.author})&${hastags}`);
// facebook.setAttribute('href' , `https://facebook.com/home/?status=${data['quote']}(${data.author})`);
})
.catch(function(err) {//if any error we can see it in the console ;
// Error :(
console.log(err);
textQuote.textContent=err;
});
}
});
Also see: Tab Triggers