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

Auto Save

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

              
                <div class="container h-100">
  
  <div class="row align-items-center justify-content-center h-100">
    
    <div class="col-md-8 col-lg-6 p-3">
      <div class="bg-light shadow p-5">
        <div id="citation" class="text-center">
          La vie est un mystère qu'il faut vivre, et non un problème à résoudre.
        </div>
        <div class="bg-secondary w-25 mx-auto p-1 my-4"></div>
        <div id="auteur" class="text-center">
          Gandhi
        </div>
      </div>
      
      <div id="nouveau" class="mt-2 text-center p-3 text-white font-weight-bold text-uppercase">
        Nouvelle citation
      </div>
    </div>
    
  </div>
  
</div>
              
            
!

CSS

              
                html, body {
  background: #5C258D;
  background: -webkit-linear-gradient(to right, #4389A2, #5C258D);
  background: linear-gradient(to right, #4389A2, #5C258D);
  height: 100%;
  min-width: 500px;
}

#citation {
  font-size: 2em;
  font-family: 'Satisfy', curve;
  line-height: 1.3em;
  letter-spacing: 1px;
}

#citation:before {
    content: open-quote;
}

#citation:after {
    content: close-quote;
}

#auteur {
  font-size: 1.5em;
  font-style: italic;
}

#nouveau {
  background: #ff9966;
  background: -webkit-linear-gradient(to right, #ff5e62, #ff9966);
  background: linear-gradient(to right, #ff5e62, #ff9966);
  cursor: pointer;
}
              
            
!

JS

              
                // Variables DOM
const buttonQuote = document.querySelector("#nouveau"); // button

const quoteContent = document.querySelector("#citation"); //textContent

const quoteAuthor = document.querySelector("#auteur"); //AuthornName

// Array quote
const quote = [
  [
    "La vie est un mystère qu'il faut vivre, et non un problème à résoudre.",
    "Gandhi",
  ],
  ["Le plus grand risque est de ne prendre aucun risque.", "Mark Zuckerberg"],
  ["Méritez votre statut de leader chaque jour.", "Mickael Jordan"],
  ["Soyez le changement que vous voulez voir dans le monde.", "Gandhi"],
  [
    "A chaque fois que vous vous retrouvez du même côté que la majorité, il est temps de prendre du recul, et de réfléchir.",
    "Mark Twain",
  ],
  [
    "Seulement ceux qui prendront le risque d’aller trop loin découvriront jusqu’où on peut aller.",
    "T.S Elliot",
  ],
  ["Le succès c’est tomber sept fois, se relever huit.", "Proverbe japonais"],
  [
    "Dans vingt ans vous serez plus déçus par les choses que vous n’avez pas faites que par celles que vous avez faites. Alors sortez des sentiers battus. Mettez les voiles. Explorez. Rêvez. Découvrez.",
    "Mark Twain",
  ],
  [
    "Si vous attendez pour agir, tout ce que vous gagnerez, avec le temps, c’est de l’âge.",
    "Brian Tracy",
  ],
  [
    "Quand on concentre son attention sur un seul projet, l’esprit suggère constamment des idées et des améliorations qui lui échapperaient s’il était occupé avec plusieurs projets en même temps.",
    "P.T. Barnum",
  ],
  [
    "Se dédier à faire tout ce que l’on peut pour aider les autres à obtenir ce qu’ils veulent, c’est la clé du succès.",
    "Brian Sher",
  ],
  [
    "Si vous pensez que vous êtes trop petit pour avoir de l’impact, essayez d’aller au lit avec un moustique.",
    "Anita Roddick",
  ],
  [
    "Ne jugez pas chaque jour sur ce que vous récoltez, mais sur les graines que vous semez.",
    "Robert Louis Stevenson",
  ],
  ["L’action est la clé fondamentale de tout succès.", "Pablo Picasso"],
  [
    "Le succès, c’est se promener d’échecs en échecs tout en restant motivé.",
    "Winston Churchill",
  ],
  [
    "Votre avenir est créé par ce que vous faîtes aujourd’hui, pas demain.",
    "Robert T. Kiyosaki",
  ],
  [
    "Ne vous découragez pas, c’est souvent la dernière clef du trousseau qui ouvre la porte.",
    "Zig Ziglar",
  ],
  [
    "Pour gagner votre vie, apprenez à l’école. Pour gagner une fortune, apprenez par vous-même.",
    "Brian Tracy",
  ],
  [
    "Les gagnants trouvent des moyens, les perdants des excuses…",
    "F. D. Roosevelt",
  ],
  [
    "Vous n’êtes jamais trop vieux pour vous fixer de nouveaux buts, ou rendre vos rêves réalité.",
    "C.S. Lewis",
  ],
  [
    "Un pessimiste voit la difficulté dans chaque opportunité. Un optimiste voit une opportunité dans chaque difficulté.",
    "Winston Churchill",
  ],
];

// Using my variable randomIndex, I will generate a random quote, using randomQuote[0] for the quote and randomQuote[1] for the author's name.
buttonQuote.addEventListener("click", () => {
  const randomIndex = Math.floor(Math.random() * quote.length);
  const randomQuote = quote[randomIndex];

  quoteContent.textContent = randomQuote[0];
  quoteAuthor.textContent = randomQuote[1];
});

              
            
!
999px

Console