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.
<div class="container">
<!-- random quote machine -->
<div class="wrapper quote-machine border blue">
<header class="border blue">
<h1>Random Programmers Quote Machine</h1>
<span class="version border blue">ver:1.1</span>
</header>
<main class="border blue">
<blockquote id="quote"></blockquote>
<div class="block">
<a href="#" id="newQuoteBtn" class="btn">New quote</a>
<span id="tweet-wrapper">
</span>
</div>
</main>
<footer class="border blue">
<p class="page-author">Coded and designed by <br/><a href="https://markostefanovic.github.io/" class="brackets" target="_blank">Marko Stefanovic</a><br/>for FreeCodeCamp © 2016</p>
</footer>
</div>
<div class="wrapper mem border blue">
<div class="cells">
<header><h2>MEM.</h2></header>
<ul class="border red">
<li id="0">/<br/><span class="module"></span></li>
<li id="1">/<br/><span class="module"></span></li>
<li id="2">/<br/><span class="module"></span></li>
<li id="3">/<br/><span class="module"></span></li>
<li id="4">/<br/><span class="module"></span></li>
<li id="5">/<br/><span class="module"></span></li>
<li id="6">/<br/><span class="module"></span></li>
<li id="7">/<br/><span class="module"></span></li>
<li id="8">/<br/><span class="module"></span></li>
<li id="9">/<br/><span class="module"></span></li>
<li id="10">/<br/><span class="module"></span></li>
<li id="11">/<br/><span class="module"></span></li>
<li id="12">/<br/><span class="module"></span></li>
<li id="13">/<br/><span class="module"></span></li>
<li id="14">/<br/><span class="module"></span></li>
<li id="15">/<br/><span class="module"></span></li>
<li id="16">/<br/><span class="module"></span></li>
<li id="17">/<br/><span class="module"></span></li>
</ul>
</div>
</div>
</div>
/* ############ MIXINS ############## */
// neon borders
@mixin neon-border($color,$rgba,$inset,$x,$y){
// $color - border color, $rgba - shadow, $inset - true/false
border: 2px solid $color;
@if $inset == 'true' {
-webkit-box-shadow: 0px 0px $x $y $rgba, inset 0px 0px $x $y $rgba;
-moz-box-shadow: 0px 0px $x $y $rgba, inset 0px 0px $x $y $rgba;
box-shadow: 0px 0px $x $y $rgba, inset 0px 0px $x $y $rgba;
}@else if $inset == 'false'{
-webkit-box-shadow: 0px 0px $x $y $rgba;
-moz-box-shadow: 0px 0px $x $y $rgba;
box-shadow: 0px 0px $x $y $rgba;
}
}
// scan line and opacity effect animation
@mixin scanOpacity($background){
// if $background == true move background if no just animate opacity
-webkit-animation: ScanLine 10s ease-in-out infinite;
-moz-animation: ScanLine 10s ease-in-out infinite;
animation: ScanLine 10s ease-in-out infinite;
@if $background == "true"{
@-webkit-keyframes ScanLine {
0%{background-position:51% 0%; opacity: 0.9}
10%{opacity: 0.8}
20%{opacity: 0.7}
30%{opacity: 0.8}
40%{opacity: 0.9}
50%{background-position:50% 100%;opacity: 1}
60%{opacity: 0.9}
70%{opacity: 0.6}
80%{opacity: 0.9}
90%{opacity: 0.8}
100%{background-position:51% 0%;opacity: 0.9}
}
@-moz-keyframes ScanLine {
0%{background-position:51% 0%; opacity: 0.9}
10%{opacity: 0.8}
20%{opacity: 0.7}
30%{opacity: 0.8}
40%{opacity: 0.9}
50%{background-position:50% 100%;opacity: 1}
60%{opacity: 0.9}
70%{opacity: 0.6}
80%{opacity: 0.9}
90%{opacity: 0.8}
100%{background-position:51% 0%;opacity: 0.9}
}
@keyframes ScanLine {
0%{background-position:51% 0%; opacity: 0.9}
10%{opacity: 0.8}
20%{opacity: 0.7}
30%{opacity: 0.8}
40%{opacity: 0.9}
50%{background-position:50% 100%;opacity: 1}
60%{opacity: 0.9}
70%{opacity: 0.6}
80%{opacity: 0.9}
90%{opacity: 0.8}
100%{background-position:51% 0%;opacity: 0.9}
}
}@else{
@-webkit-keyframes ScanLine {
0%{opacity: 0.8}
10%{opacity: 0.5;}
20%{opacity: 0.9}
30%{opacity: 0.7}
40%{opacity: 0.9}
50%{opacity: 1}
60%{opacity: 0.9}
70%{opacity: 0.6}
80%{opacity: 0.9}
90%{opacity: 0.8}
100%{opacity: 0.9}
}
@-moz-keyframes ScanLine {
0%{opacity: 0.8}
10%{opacity: 0.5}
20%{opacity: 0.9}
30%{opacity: 0.7}
40%{opacity: 0.9}
50%{opacity: 1}
60%{opacity: 0.9}
70%{opacity: 0.6}
80%{opacity: 0.9}
90%{opacity: 0.8}
100%{opacity: 0.9}
}
@keyframes ScanLine {
0%{opacity: 0.8}
10%{opacity: 0.5}
20%{opacity: 0.9}
30%{opacity: 0.7}
40%{opacity: 0.9}
50%{opacity: 1}
60%{opacity: 0.9}
70%{opacity: 0.6}
80%{opacity: 0.9}
90%{opacity: 0.8}
100%{opacity: 0.9}
}
}
}
// glitch effect
@mixin glitchEffect(){
-webkit-animation: Glitch 10s ease-in-out infinite;
-moz-animation: Glitch 10s ease-in-out infinite;
animation: Glitch 10s ease-in-out infinite;
@-webkit-keyframes Glitch {
0%{}
9.9%{-webkit-transform:skew(0deg);}
10%{-webkit-transform:skew(1deg);}
10.1%{-webkit-transform:skew(0deg);}
89.9%{-webkit-transform:skew(0deg);}
90%{-webkit-transform:skew(-4deg);}
90.1%{-webkit-transform:skew(0deg);}
100%{}
}
@-moz-keyframes Glitch {
0%{}
9.9%{-webkit-transform:skew(0deg);}
10%{-webkit-transform:skew(1deg);}
10.1%{-webkit-transform:skew(0deg);}
89.9%{-webkit-transform:skew(0deg);}
90%{-webkit-transform:skew(-4deg);}
90.1%{-webkit-transform:skew(0deg);}
100%{}
}
@keyframes Glitch {
0%{}
9.9%{-webkit-transform:skew(0deg);}
10%{-webkit-transform:skew(1deg);}
10.1%{-webkit-transform:skew(0deg);}
89.9%{-webkit-transform:skew(0deg);}
90%{-webkit-transform:skew(-4deg);}
90.1%{-webkit-transform:skew(0deg);}
100%{}
}
}
@mixin cursorBlink($time){
-webkit-animation: Blink $time ease infinite;
-moz-animation: Blink $time ease infinite;
animation: Blink $time ease infinite;
@-webkit-keyframes Blink {
0%{opacity: 0}
50%{opacity: 1}
100%{opacity: 0}
}
@-moz-keyframes Blink {
0%{opacity: 0}
50%{opacity: 1}
100%{opacity: 0}
}
@keyframes Blink {
0%{opacity: 0}
50%{opacity: 1}
100%{opacity: 0}
}
}
/* ############ END/MIXINS ############## */
/* ############ COLORS ############## */
$bukner : #141f23;
$black-pearl : #051D29;
$spray: #93EDF5;
$picton-blue: #4BA0E3;
$iceberg:#d9f2f4;
$dairy-cream:#F7E3AF;
$blosom: #D4AFB9;
$burnt-siennaRGBA:rgba(240, 93, 94, 0.78);
$cream-canRGBA: rgba(239, 199, 97, 0.78);
$curious-blueRGBA: rgba(16, 81, 139, 0.78);
$aquaRGBA: rgba(0, 255, 255, 0.83);
/* ############ END/COLORS ############## */
/* ############ TYPOGRAPHY ############## */
h1{
font-family: 'Black Ops One', cursive;
font-size: 18px;
@include media('>=tablet'){
font-size: 22px;
}
margin: 10px;
}
h2{
font-family: 'Black Ops One', cursive;
font-size: 30px;
margin: 10px;
}
// links
a{
color: $iceberg;
text-decoration: none;
transition: all 1s ease;
// square brackets
&.brackets{
padding-bottom: 2px;
&::before{
content:'[ ';
}
&::after{
content:' ]';
}
}
&:hover, &:active, &:focus{
background: $iceberg;
color: black;
}
}
/* ############ END/TYPOGRAPHY ############## */
/* ############ BUTTONS ############## */
.btn{
padding: 5px;
margin: 5px;
color:black;
background: $spray;
text-decoration: none;
text-transform: uppercase;
text-shadow: none;
font-weight: bold;
// neon border effect
@include neon-border($spray,$curious-blueRGBA,'false',4px,2px);
&:hover{
background: transparent;
color: $spray;
text-shadow: 0px 0px 5px $aquaRGBA;
}
}
/* ############ END/BUTTONS ############## */
/* ############ BASE ############## */
body{
font-size: 16px;
font-family: 'Source Code Pro', monospace;
color: $spray;
text-shadow: 0px 0px 5px $aquaRGBA;
background:$black-pearl;
// background animation
@include scanOpacity('false');
@include media('>tablet'){
background:$black-pearl url('https://markostefanovic.github.io/random-quote-generator/images/back.png') repeat 300% 300% ;
@include scanOpacity('true');
}
}
//neon border
.border{
&.blue{
@include neon-border($picton-blue,$curious-blueRGBA,'true',4px,2px);
}
&.red{
@include neon-border($blosom,$burnt-siennaRGBA,'false',2px,1px);
}
}
.cursor{
color: $spray;
background: transparent;
text-shadow: 0px 0px 5px $aquaRGBA;
// blinking cursor animation
@include cursorBlink(2s);
}
.float-left{
float:left;
}
.clear{
clear: both;
}
/* ############ END/BASE ############## */
/* ############ CONTAINER ############## */
.container{
max-width: 800px;
margin: 0 auto;
min-width: 300px;
.wrapper{
padding: 2px;
// glitch effect
@include glitchEffect();
}
}
/* ############ END/CONTAINER ############## */
/* ############ QUOTE - MACHINE ############## */
.quote-machine{
float: left;
margin: 5px;
width: 95vw;
@include media('>=tablet'){
width: 600px;
}
}
header{
margin-bottom: 2px;
min-height: 50px;
position: relative;
span{
position:absolute;
right: 5px;
bottom: 5px;
}
}
main{
margin-bottom: 2px;
padding: 5px;
position: relative;
min-height: 300px;
@include media('<tablet','landscape'){
min-height: 170px;
}
blockquote{
position: relative;
min-height: 130px;
margin: 10px;
.author{
margin-top: 10px;
float: right;
}
.warning{
padding-top: 10px;
text-align: center;
>span{
color: black;
background: $blosom;
font-weight: bold;
text-transform: uppercase;
text-shadow: none;
}
}
}
.block{
position: absolute;
bottom: 15px;
}
}
.page-author{
text-align: center;
}
footer{
padding-top: 5px;
}
/* ############ END/QUOTE - MACHINE ############## */
/* ############ MEMORY MODULE ############## */
.mem{
width: 105px;
margin: 5px;
padding: 2px;
float: left;
ul{
padding-left: 2px;
padding-top: 2px;
li{
list-style:none;
display: inline-block;
margin: -4px;
}
}
.module{
margin: 3px;
width: 6px;
height: 16px;
display: inline-block;
background: $spray;
@include neon-border($spray,$aquaRGBA,'false',2px,1px);
}
header{
margin: 5px 5px 5px 0;
min-height: 20px;
h2{
font-size: 30px;
margin: 5px;
}
}
.cell{
float: left;
}
// when clicked on new quote
.opened{
color:$blosom;
text-shadow: 0px 0px 5px $burnt-siennaRGBA;
.module{
transition: background 2s,border 2s;
background: $blosom;
@include neon-border($blosom,$burnt-siennaRGBA,'false',2px,1px);
}
}
}
/* ############ END/MEMORY MODULE ############## */
$(function() {
var quotes = [{
quote: 'Java is to JavaScript what Car is to Carpet.',
author: 'Chris Heilmann',
link: '#'
}, {
quote: 'It\'s hard enough to find an error in your code when you\'re looking for it, it\'s even harder when you\'ve assumed your code is error-free.',
author: 'Steve McConnell',
link: 'https://en.wikipedia.org/wiki/Steve_McConnell'
}, {
quote: 'If debugging is the process of removing software bugs, then programming must be the process of putting them in.',
author: 'Edsger Dijkstra',
link: 'https://en.wikipedia.org/wiki/Edsger_W._Dijkstra'
}, {
quote: 'Walking on water and developing software from a specification are easy if both are frozen.',
author: 'Edward V Berard',
link: 'https://en.wikiquote.org/wiki/Edward_V._Berard'
}, {
quote: 'Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.',
author: 'Brian Kernighan',
link: 'https://en.wikipedia.org/wiki/Brian_Kernighan'
}, {
quote: 'It\'s not at all important to get it right the first time. It\'s vitally important to get it right the last time.',
author: 'David Thomas',
link: 'https://en.wikipedia.org/wiki/Dave_Thomas_(programmer)'
}, {
quote: 'Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration.',
author: 'Stan Kelly-Bootle',
link: 'https://en.wikipedia.org/wiki/Stan_Kelly-Bootle'
}, {
quote: 'Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.',
author: 'Rick Osborne',
link: '#'
}, {
quote: 'Any fool can write code that a computer can understand. Good programmers write code that humans can understand.',
author: 'Martin Fowler',
link: 'https://en.wikipedia.org/wiki/Martin_Fowler'
}, {
quote: 'Software sucks because users demand it to.',
author: 'Nathan Myhrvold',
link: 'https://en.wikipedia.org/wiki/Nathan_Myhrvold'
}, {
quote: 'Linux is only free if your time has no value. ',
author: 'Jamie Zawinski',
link: 'https://en.wikipedia.org/wiki/Jamie_Zawinski'
}, {
quote: 'The first 90p of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.',
author: 'Tom Cargill',
link: 'https://en.wikipedia.org/wiki/Ninety-ninety_rule'
}, {
quote: 'Programming can be fun, so can cryptography, however they should not be combined.',
author: 'Ben Shneiderman',
link: 'https://en.wikipedia.org/wiki/Ben_Shneiderman'
}, {
quote: 'Copy and paste is a design error.',
author: 'David Parnas',
link: 'https://en.wikipedia.org/wiki/David_Parnas'
}, {
quote: 'Before software can be reusable it first has to be usable.',
author: 'Ralph Johnson',
link: 'https://en.wikipedia.org/wiki/Ralph_Johnson_(computer_scientist)'
}, {
quote: 'When someone says \'I want a programming language in which I need only say what I want done\' give him a lollipop.',
author: 'Alan Perlis',
link: 'https://en.wikipedia.org/wiki/Alan_Perlis'
}, {
quote: 'Computers are good at following instructions, but not at reading your mind.',
author: 'Donald Knuth',
link: 'https://en.wikipedia.org/wiki/Donald_Knuth'
}, {
quote: 'Any code of your own that you haven\'t looked at for six or more months might as well have been written by someone else.',
author: 'Eagleson\'s law',
link: '#'
}];
// vars
var i = 0;
var x = 0;
var result = [];
var $element = $('#quote');
var $tweet = $('#tweet-wrapper');
var htmlOutput;
// IIFE - get array of random numbers
(function() {
var minNum = 0;
var maxNum = quotes.length;
var randomNum = 0;
while (result.length < maxNum) {
randomNum = Math.floor(Math.random() * (maxNum - minNum)) + minNum;
// if random number doesnt exists in array push it to array
if (result.indexOf(randomNum) > -1) continue;
result.push(randomNum);
}
})();
function output() {
// x iterates quotes obj
if (x < quotes.length) {
var num = result[x];
if (quotes[num].link == '#') {
htmlOutput = '<p>' + quotes[num].quote + '</p>' + '<footer><a href="#" class="brackets author">' + quotes[num].author + '</a><span class="cursor blink">▮</span></footer>';
} else {
htmlOutput = '<p>' + quotes[num].quote + '</p>' + '<footer><a href="' + quotes[num].link + '" target="_blank" class="brackets author">' + quotes[num].author + '</a><span class="cursor blink">▮</span></footer>';
}
$('#' + num).addClass('opened');
$tweet.html('<a href="https://twitter.com/intent/tweet?text=' + quotes[num].quote + '-' + quotes[num].author + '" class="btn" target="_blank">Tweet Quote</a>');
} else {
htmlOutput = '<div class="warning"><span>WARNING</span><p> No more new quotes <span class="cursor blink">▮</span></p></div>';
}
//$element.html(htmlOutput);
x++;
return render();
};
output();
var isTag, char, text;
function render() {
//console.log('i',i);
text = htmlOutput.slice(0, i++);
if (text === htmlOutput) return i = 0;
$element.html(text + '▮');
char = text.slice(-1);
if (char === '<') isTag = true;
if (char === '>') isTag = false;
if (isTag) return render();
return setTimeout(render, 20);
};
$('#newQuoteBtn').on('click', function() {
output();
});
});
Also see: Tab Triggers