Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- <!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>
              
            
!

CSS

              
                /*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;
    }
  }
}
              
            
!

JS

              
                $(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)
  })
});
              
            
!
999px

Console