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 URL's added here will be added as <link>
s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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">
<title>interactive mini graphic novel</title>
<meta name="description" content="Interactive mini visual-graphic-novel with two different scenes.">
<meta name="keywords" content="game, interactive, graphic-novel, javascript, css, html">
</head>
<body>
<aside class="context">
<h1> What do you want to do?</h1>
<p>| Make your choice! |</p>
<p class="thanks" style="visibility:hidden;">THANKS FOR PLAYING !</p>
<span class"hint">
<div class="button hint" style="">
<a class="start-button option wobble-vertical-on-hover hint">Start !</a>
<a class="stop-button option wobble-vertical-on-hover">Stop playing !</a>
</div>
</span>
</aside>
<!-- die Id wird in JS genutzt, um einen Start-Bildschrim zu erschaffen -->
<div id="gamestart"class="main-content"> <!-- wird genutzt, um den main-content zu steuern und zu positionieren -->
<div class="illustration">
<img src="https://image.flaticon.com/icons/svg/2070/2070807.svg" width="100px" id="signpost" style="visibility:hidden"/>
<div class="figure">
<img src="https://image.flaticon.com/icons/svg/3131/3131782.svg" width="100px"/>
</div>
<!-- hier ist der Wrapper für die Sprechblasen. Es enthält beide Sprechblasen einzeln, die durch JS gesteuert werden -->
<div id="bubbletoggle1" class="bubble1" style="visibility:hidden;">
<a class="bubble bubble1 anim-typewriter ">Ah! That was a good decision! Now a nice cup of tea...would you set the kettle on?</a>
</div>
<div id="bubbletoggle2" class="bubble2" style="visibility:hidden;">
<a class="bubble bubble2 anim-typewriter">What a lovely day, isn't it? And such charming strangers visiting!</a>
</div>
<!-- Person-active-Container und beide Scenentypen, sowie alle einzelnen Objekte. Wird gesteuert über JS -->
<div class="person-type home-body active"> <!--- hier ist die home-scene mit dazugehörigen Objekten -->
<div class="scenery">
<img src="https://image.freepik.com/free-vector/living-room-interior-with-panoramic-window-night-time_33099-1735.jpg" class="backgroundimg"/>
</div>
<div class="background-items">
<img src="https://image.flaticon.com/icons/svg/214/214283.svg" width="100px" height="400px"/>
</div>
<div class="foreground-items">
<img src="https://image.flaticon.com/icons/svg/198/198916.svg" width="65px" style="margin-left:-10%;"/>
<img src="https://image.flaticon.com/icons/svg/3145/3145435.svg" width="65px" style="padding-left:30%;"/>
</div>
</div>
<div class="person-type outdoor-person"> <!-- hier ist die outdoor-scene mit dazugehörigen Objekten -->
<div class="scenery">
<img src="https://image.freepik.com/free-vector/natural-morning-landscape-with-hills-camping-tent-meadow-vector-illustration_126523-4.jpg" class="backgroundimg" style="
"/>
</div>
<div class="background-items">
<img src="https://image.flaticon.com/icons/svg/2909/2909956.svg" height="100px"/>
<img src="https://image.flaticon.com/icons/svg/1387/1387679.svg" height="60px" style="padding:10px;"/>
</div>
<div class="foreground-items">
<img src="https://image.flaticon.com/icons/svg/124/124553.svg" style="width:50px;"/>
</div>
</div>
</div><!-- illustration-div ende -->
<!-- Der Option-wrapper beinhaltet beide Scenen-optionen -->
<div class="option-wrapper ">
<a class="option active wobble-vertical-on-hover homeoption hint" data-option="home"> I'm gonna read a nice book and stay in.</a>
<a class="option wobble-vertical-on-hover outdooroption hint" data-option="outdoor"> I'm gonna explore the wide world and beyond!</a>
</div>
</div><!-- Ende des main-content -->
</body>
</html>
html{
height: 100%;
}
body {
background-size:cover;
font-family: "Comic Sans MS",Helvetica, sans-serif;
border: 1px dashed #ffffff;
border-radius:30%;
box-shadow: 0px 0px 350px; #000000;;
background: radial-gradient(#28427B,#14213D,#0d001f);
justify-content:center;
background-position: center;
}
/* Hint lenkt den User durch das Spiel und die einzelnen Optionen. 'Hint' wird an bestimmten Stellen auftauchen, um den User zu einem bestimmten Zeitpunkt bestimmte Optionen zu geben*/
.hint{
-moz-border-radius: 200px/200px;
-webkit-border-radius: 200px 200px;
border-radius: 200px/200px;;
border:1px solid #52c7aa;
width:auto;
height:auto;
outline:none;
-webkit-animation-name: hintPulse;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
}
@-webkit-keyframes hintPulse {
from { -webkit-box-shadow: 0 0 3px #0c2720; }
50% { -webkit-box-shadow: 0 0 21px #52c7aa; }
to {-webkit-box-shadow: 0 0 12px #246E5B; }
}
/*Start und Stop button*/
.button{
display: flex;
position: center;
margin:0em auto;
background: rgba(255, 255, 255, 0.25);
border-radius: 50px;
box-shadow:0px 0px 15px #000000;
padding: 5px;
max-width: 300px;
font-size: 15px;
line-height: 1.2;
}/* Wir genutztz, um per JS zu steuern, wann der Inhalt auftaucht, wenn die buttons gedrückt werden*/
#gamestart{
visibility:hidden;
}
#gamestop{
visibility:hidden;
}/*Danke-Text am Ende des Spiels */
.thanks{
border-radius:50%;
z-index:-5;
margin: 5em auto 5;
text-align: center;
animation: pulse 2s infinite;
}
@keyframes pulse{
0% {transform: scale(0.95);}
70% {transform: scale(1);}
100% {transform: scale(0.95);}
} /* formatiert den div-container, wo Titel und untertitel drinstehen*/
.context {
text-align: center;
color: #ffffff;
max-width: 700px;
margin: 2em auto;
padding:10px;
}
h1 {
font-familiy:"Cursive", Helvetica;
font-variant:small-caps;
margin: 2em 0;
padding:10px;
color: #fff;
border-bottom: 1px;
border-bottom-color:#ffffff;
box-shadow: 0px 0px 15px #000000;
border-bottom-style:solid;
border-radius:50px;
}
a {
overflow:hidden;
text-decoration: none;
color: #ffffff;
padding: 4px 0;
border: 1px;
}/*formatiert Sprechblase generell*/
.bubble {
z-index:4;
min-width: 0px;
max-width: 210px;
max-height:50px;
font-size: 15px;
line-height: 1.2;
display:flex;
text-align: center;
position: absolute;
border-radius: 50px;
margin-right: auto;
margin-left: auto;
left: 85%;
right: 0;
top:50%;
padding:1px;
}/* Da die Scenen verschiedene backgrounds haben, werden den jeweiligen Sprechblasen verschiedene background-colors gegeben, damit sie gut zu sehen sind*/
.bubble.bubble1{
background:rgba(255, 255, 255, 0.30);
padding: 6px 6px 4px;
}
.bubble.bubble2{
background:rgba(26, 22, 95, 0.55);
padding: 6px 6px 4px;
}/* Animation für die Sprechblase*/
.anim-typewriter{
animation: typing 7s steps(8,end) infinite normal both;
-webkit-animation-duration: 7s;
}
@keyframes typing{
from{width: 0;}
to{width: 20em;}
}/*Ab hier sind im Content zusehende Objekte /Bilder definiert*/
.main-content {
max-width: 700px;
margin: 0em auto 0;
text-align: center;
max-height:500px;
overflow:hidden;
}
.illustration {
position: relative;
align-self: flex-end;
margin: auto;
height: 250px;
width: 250px;
}/* styled signpost am Anfang. Da er einzeln in JS gesteuert wird, wird er extra gestyled */
#signpost{
position:absolute;
width:150px;
margin-top:135px;
margin-left:-150px;
}/* styled position der svg's und gesamten scenen */
.figure,
.scenery,
.background-items,
.foreground-items {
position: absolute;
left: 0;
right: 0;
margin: auto;
}/* styled scenen-wechsel*/
.scenery {
transition: all 200ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index:-2;
}/* Styled die Hintergrundbilder der Scenen */
.backgroundimg{
border-radius:50%;
margin-left:-73%;
width:626px;
height:335px;
box-shadow: 0px 0px 15px #000000;
}/* Styled die einzelnen Objekte/svg's */
.background-items {
transition: all 200ms cubic-bezier(0.68, -0.55, 0.265, 1.55) 100ms;
top: 23px;
}
.foreground-items {
transition: all 300ms cubic-bezier(0.68, -0.55, 0.265, 1.55) 200ms;
margin-top:100%;
}
.home-body {
.foreground-items {
margin-left: -60px;
}
}
.outdoor-person {
.foreground-items {
margin-right: -80px;
}
}
.figure {
bottom: -30px;
margin-right: -200px;
}
.person-type > div {
transform: scale(0);
opacity: 0;
}
.person-type.active > div {
transform: scale(1);
opacity: 1;
}/* Styled die auswählbaren Optionen als div gesamt*/
.option-wrapper {
display: flex;
position: center;
margin:8em auto;
background: rgba(255, 255, 255, 0.25);
border-radius: 50px;
padding: 5px;
max-width: 300px;
font-size: 15px;
line-height: 1.2;
box-shadow: 0px 0px 15px #000000;
}/* Syteld die Optionen im div-option-wrapper*/
.option {
transition: all 200ms ease;
padding: 10px 10px 8px;
width: 50%;
border-radius: 50px;
cursor: pointer;
color: #ffffff;
}/* gibt aktiver Option style */
.active {
background: #FFB200;
pointer-events: none;
color:#000000;
}
.option:hover: {
text-decoration: none;
}
/*Ab hier sind die Anweisungen für die Hover-Animation der Optionen. Für "Wiggle" sind die einzelnen Bewegungen auch Prozente aufgeteilt, damit der Effekt entsteht. */
.wobble-vertical-on-hover {
display: inline-block;
vertical-align: middle;
-webkit-transform: perspective(1px) translateZ(0);transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
}
.wobble-vertical-on-hover:hover, .wobble-vertical-on-hover:focus, .wobble-vertical-on-hover:active {
-webkit-animation-name: wobble-vertical-on-hover;
animation-name: wobble-vertical-on-hover;
-webkit-animation-duration: 1s;
animation-duration: 1.5s;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: 1;
animation-iteration-count: infinite;
}/* Bewegungen der Animation wobble, aufgeteilt nach Prozent*/
@keyframes wobble-vertical-on-hover {
16.65% {-webkit-transform: translateY(8px);transform: translateY(8px);}
33.3% {-webkit-transform: translateY(-6px);transform: translateY(-6px);}
49.95% {-webkit-transform: translateY(4px);transform: translateY(4px);}
66.6% {-webkit-transform: translateY(-2px);transform: translateY(-2px);}
83.25% {-webkit-transform: translateY(1px);transform: translateY(1px);}
100% {-webkit-transform: translateY(0);transform: translateY(0);}
}
// Hier die einzelnen Aktionen, die ausgelöst werden, wenn auf den 'start-button' geklickt wird
$(".start-button").on("click", function() {
$(".main-content").removeAttr("id", "gamestart");
$(".thanks").css({"visibility": "hidden"});
$("#signpost").css({"visibility": "visible"});
// 'hint' gibt dem User Hinweise, wo hingeklickt werden kann und leitet den User durch das Spiel und die Optionen
$(".button").removeClass("hint");
$(".start-button").removeClass("hint");
$(".option-wrapper").addClass("hint");
});
//Funktion und einzelne Aktionen, die ausgeführt werden sollen
$(".stop-button").on("click", function() {
$(".main-content").attr("id", "gamestop");
$(".bubble").hide();
$("#signpost").removeAttr("style","visible");
$(".thanks").css({"visibility": "visible"});
$(".start-button").addClass("hint");
$(".button").addClass("hint");
//wenn der stop-button geklick wird, muss das lightning entfernt werden, da option gedrückt wurde
$(".stop-button").removeClass("hint");
//hiermit wird die Klasse 'hint' den beiden Scenen-Optionen wieder hinzugefügt, die während der Interaktion mit den Scenen jeweils entfernt wurden. Somit sind beide Optionen beim Start erneut mit 'hint' versehen.
$(".homeoption").addClass("hint");
$(".outdooroption").addClass("hint");
});
//Ab hier die Funktion und Aktionen, wenn die klasse option geklickt wird
$(".option").on("click", function() {
$(".person-type").removeClass("active");
$(".option").removeClass("active");
$(this).addClass("active");
var type = $(this).data("option");
console.log($(type));
// Ab hier die Funktion und einzelnen, ausgelösten Aktionen, wenn auf die Option 'home' geklickt wird
setTimeout(function() {
if (type === "home") {
$(".home-body").addClass("active");
$("#signpost").css({"visibility": "hidden"});
$("#bubbletoggle1").css({"visibility": "visible"});
// Hier der Wechsel der Sprachblasen
$(".bubble2").hide();
$(".bubble1").show();
$(".stop-button").addClass("hint");
$(".homeoption").removeClass("hint");
}
//Ab hier die einzelnen Aktionen, wenn auf die Option 'outdoor' geklickt wird
else if (type === "outdoor") {
$(".outdoor-person").addClass("active");
$(".stop-button").addClass("hint");
$(".homeoption").addClass("hint");
$(".outdooroption").removeClass("hint");
$("#signpost").css({"visibility": "hidden"});
$("#bubbletoggle2").css({"visibility": "visible"});
// Hier der Wechsel der Sprechblasen
$(".bubble1").hide();
$(".bubble2").show();
}
}
, 700);
});
Also see: Tab Triggers