cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="box">
  <h1 class='header'>Random Insults Generator</h1>
  <p class="instructions">Click the button below to generate a random insult.</p>
  <p class='paragraph'><em>Insults will appear here</em></p>
  <div class="btn" onclick="myFunction()"><p class="btn-text">Insult!</p></div>
</div>


            
          
!
            
              body{
  background: url('https://www.toptal.com/designers/subtlepatterns/patterns/geometry.png');
}
.box{
  width: 90%;
  max-width: 700px;
  height: 300px;
  margin: 20px auto;
  padding: 10px;
/*   background: #333; */
  font-family: sans-serif;
  padding: 15px;
  text-align: center;
  color: white;
  border-radius: 10px;
  display:flex;
  flex-flow: column;
  align-items: center;
  background: rgba(102, 0, 102,.75)
}
.paragraph{
  background: #111;
  width: 90%;
  margin: 20px auto;
  padding: 10px 0;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: bold
}
.paragraph p{

}
.btn{
  background: rgb(0, 102, 102);
  width: 100px;
  padding: 5px;
  border-radius: 10px;
  display: flex;
  justify-content: center; 
  cursor: pointer
  transition: all .3s ease;
}
.btn:hover{
  background: rgb(10, 112, 112);
}
.btn p{
  font-weight:bold;
  padding: 0;
}
            
          
!
            
              var adj = ['stinky','ugly'];
var noun1 = ['giraffe','warthog'];
var noun2 = ['rump','snout','flank','hoof','tooth','tail','fur','leg','fang'];
var insult = '';

function rand(thing){
 return thing[Math.floor(Math.random() * thing.length)];
}

function myFunction(){
  insult = '';
  document.getElementsByClassName("paragraph")[0].innerHTML = insult;
}
            
          
!
999px
Loading ..................

Console