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 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.
<!-- <!DOCTYPE html> -->
<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>Lorem ipsum generator</title>
</head>
<body>
<div class="website">
<div class="container">
<form class="form js_form" action="#">
<div class="form_field">
<label for="quantity" class="form_label">Nombre</label>
<input id="quantity" class="form_input" name="quantity" min="1" max="10" type="number" value="1">
</div>
<div class="form_field">
<label for="type" class="form_label">Type</label>
<select id="type" class="form_input" name="type" >
<option value="paragraphs">Paragraphes</option>
<option value="words">Mots</option>
<option value="bytes">Caractères</option>
</select>
</div>
<div class="form_field">
<label for="category" class="form_label">Catégorie</label>
<select id="category" class="form_input" name="category" >
<option value="Pangrammes">Pangrammes</option>
<option value="Alsacreations">Alsacreations</option>
</select>
</div>
<div class="form_field">
<textarea class="hidden" name="Alsacreations">Lorem Elsass ipsum tellus in, barapli salu schpeck picon bière ullamcorper gal ac Gal.
Carola et ornare nüdle libero Heineken quam, Coopé Truchtersheim kartoffelsalad hopla non merci.
vielmols placerat amet Chulia.
Roberstau knepfle morbi sagittis eleifend porta non aliquam DNA, varius suspendisse sit hop tchao.
bissame Pellentesque Kabinetpapier pellentesque rucksack Huguette tellus bredele ante leo libero, munster ornare rhoncus météor kougelhopf rossbolla Verdammi nullam RichardSchirmeck elementum wurscht Salutbisamme vulputate schneck Pfourtz!
Hans hopla mollis hopla Oberschaeffolsheim habitant Strasbourg und Christkindelsmärik id, sed dolor flammekueche commodo mamsell amet, Spätzle consectetur risus, sit Racing. semper geïz Wurschtsalad gravida Miss.
Dahlias schnaps mänele réchime hoplageiss bissame chambon dignissim leverwurscht Salu.
bissame baeckeoffe id sed geht's turpis, blottkopf, lacus hopla senectus ch'ai Morbi condimentum vielmols, jetz.
los auctor, ac elit adipiscing quam. amet so kuglopf Chulien Mauris gewurztraminer Gal.
Leo wie yeuh. Oberschaeffolsheim sit Yo. ftomi! s'guelt tristique messti. Bischheim knack libero. purus eget turpis dui.</textarea>
<textarea class="hidden" name="Pangrammes">Portez ce vieux whisky au juge blond qui fume. Ce juge a très soif.
Hier, au zoo, j'ai vu dix guépards, cinq zébus, un yak et le wapiti fumer.
Joyeux, ivre, fatigué, le nez qui pique, Clown Hary skie dans l’ombre a fin de l’histoire est plus triste : Clown Harry, cherchant à se gratter le nez sous son embout rouge, s’est pris un sapin.
Monsieur Jack, vous dactylographiez bien mieux que Wolf. Depuis, Wolf a été viré. Hier, au zoo, j'ai vu dix guépards, cinq zébus, un yak et le wapiti fumer. Les dresseurs en PLS.
Yves fugue en BMX chez Will, qui est près du Kilimandjaro. Un road movie vertigineux et enivrant.
J’aime l’idée que le plus grand des Sex-symbols new-yorkais n’était qu’un chien dans un foyer de Brazzaville.
Il s’appelait Sambuca, le chien. Dès Noël, où un zéphyr haï me vêt de glaçons würmiens, je dîne d’exquis rôtis de bœuf au kir, à l’aÿ d’âge mûr, ...
Je vois plus ce pote je comprenais pas quand il parlait. Zut ! Je crois que le chien Sambuca préfère le whisky revigorant au doux porto.
Normal, pour un sex-symbol new yorkais.
Voyez ce koala fou qui mange des journaux et des photos dans un bungalow. Encore un scoop de Topito koala.
Portons dix bons whiskys à l'avocat goujat qui fumait au zoo. La fin de carrière du juge blond a été mouvementée et très animalière.</textarea>
<button class="btn js_submit">Générer</button>
</div>
</form>
</div>
<div class="container result">
<h2>Résultats</h2>
<div class="js_result">
</div>
</div>
</div>
</body>
</html>
/*COULEURS*/
$noir: rgba(0,0,0,1);
$noirfonce: rgba(29,31,32,1);
$noiropaque: rgba(29,31,32,.9);
$rose: rgba(152,38,114,1);
$bleu: rgba(128,155,189,1);
$blanc: rgba(255,255,255,1);
$gris: rgba(55,55,55,1);
$gris2: rgba(255,255,255,.8);
$gris3: rgba(204,204,204,1);
$padding: 20px 10px;
/*TOUS LES ELEMENTS*/
*,*:after,*:before {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
body {
margin: 0px auto;
width: 640px;
background: $noir;
color: $blanc;
font-size: 1em;
padding: $padding;
}
main {
background: $noirfonce;
}
@import url('https://fonts.googleapis.com/css2?family=Overpass:ital,[email protected],100;0,400;0,600;0,700;1,600;1,900&display=swap');
.website {
font-family: 'Overpass', sans-serif;
font-size: 16px;
overflow-x: hidden;
}
.website .container {
padding: 12px;
}
.website h2 {
display: block;
margin-bottom: 12px;
width: 100%;
font-weight: bold;
font-size: 1.2em;
}
.website p {
display: inline;
line-height: 150%;
color: $blanc;
}
.hidden {
position: absolute;
width: 0px;
height: 0px;
opacity: 0;
visibility: hidden;
}
.form,
.result {
display: flex;
flex-wrap: wrap;
flex-direction: column;
margin: 12px auto;
max-width: 600px;
@media screen and (min-width: 640px) {
flex-direction: row;
}
.form_field {
margin: 12px auto;
width: 100%;
}
@media screen and (min-width: 640px) {
.form_field {
width: 50%;
}
}
.form_label {
display: block;
margin-bottom: 6px;
font-weight: bold;
}
.form_input {
padding: 6px;
width: 96%;
height: 40px;
}
.btn {
margin-top: calc(16px + 6px);
width: 123px;
height: 40px;
background: $noir;
color: $blanc;
text-align: center;
&:hover,
&:active {
background: $blanc;
color: $noir;
cursor: pointer;
}
}
}
$(document).ready(function() {
const $result = $('.website .js_result'),
loremAlsacreations = $('.website [name="Alsacreations"]').val(),
loremPangrammes = $('.website [name="Pangrammes"]').val();
function runLoremGenerator (type,category,quantity) {
var espace = "";
if(type === 'paragraphs') {
type = "\n";
espace = "<br>";
}
else if(type === "words") {
type = " ";
espace = " ";
}
else {
type = "";
espace = "";
}
if(category === "Alsacreations") {
var categoryResult = loremAlsacreations.split(type);
}
else {
var categoryResult = loremPangrammes.split(type);
}
if(parseInt(quantity) > 10) {
quantity = 10;
}
else if(parseInt(quantity) < 1 || !quantity) {
quantity = 1;
}
let str = "";
for (let i = 0; i < quantity; i++) {
str += "<p>"+categoryResult[i]+"</p>"+espace;
}
$result.html(str);
}
$('.website .js_submit').on('click', function(e) {
e.preventDefault()
var quantity = $('.website [name="quantity"]').val(),
type = $('.website [name="type"]').val(),
category = $('.website [name="category"]').val();
$result.html("")
runLoremGenerator(type,category,quantity)
})
});
Also see: Tab Triggers