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

              
                <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Random Generator</title>
  <link href="https://fonts.googleapis.com/css?family=Playfair+Display:900" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800" rel="stylesheet">
  <link rel="stylesheet" href="animate.min.css">
  <link rel="stylesheet" href="styles.css">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
  <!-- Header Section -->
  <div class="header">
    <a href="https://calculator.institute" class="calculator-link" target="_blank">Calculators</a>
  </div>

  <div class="container">
    <div class="left">
      <div class="material opacity">Click button</div>
    </div>
    <div class="right">
      <div class="object">to begin</div>
    </div>
    <div class="random">Generate!</div>
  </div>

  <script src="script.js"></script>
</body>
</html>
              
            
!

CSS

              
                @media only screen and (min-width: 800px) {
  .object {
    font: 900 54px "Poppins", sans-serif;
    color: #0078d7;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
  }
}

@media only screen and (max-width: 800px) {
  .object {
    font: 900 40px "Poppins", sans-serif;
    color: #0078d7;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
  }
}

@media only screen and (max-width: 550px) {
  .object {
    font: 900 20px "Poppins", sans-serif;
    color: #0078d7;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
  }
}

@media only screen and (min-width: 800px) {
  .material {
    font: 800 30px "Roboto", sans-serif;
    color: #3d3d3d;
  }
}

@media only screen and (max-width: 800px) {
  .material {
    font: 800 20px "Roboto", sans-serif;
    color: #3d3d3d;
  }
}

@media only screen and (max-width: 550px) {
  .material {
    font: 800 14px "Roboto", sans-serif;
    color: #3d3d3d;
  }
}

.container {
  z-index: 1000;
  min-height: 300px;
  max-height: 1200px;
  position: block;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  font-size: 20px;
}

.left {
  background-color: #f8f9fa;
  margin-top: 175px;
  top: 0;
  left: 0;
  right: 55%;
  bottom: 0;
  position: absolute;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.right {
  transition: all 0.3s ease-in-out;
  background-color: #ffffff;
  top: 0;
  margin-top: 175px;
  left: 45%;
  right: 0;
  bottom: 0;
  position: absolute;
  box-shadow: -2px 4px 10px rgba(0, 0, 0, 0.1);
}

.random {
  position: absolute;
  text-align: center;
  bottom: 60px;
  width: 120px;
  padding: 10px;
  cursor: pointer;
  font: 600 16px "Roboto", sans-serif;
  letter-spacing: 0.5px;
  background-color: #ff6f61;
  color: #ffffff;
  font-size: 15px;
  border: none;
  border-radius: 25px;
  transition: all 0.3s ease-in-out;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.random:hover {
  background-color: #f05340;
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.material {
  animation: animate 0.5s ease-in-out;
  position: absolute;
  right: 15px;
  top: calc(10% - 2px);
  color: #0078d7;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.object {
  animation: animate 0.75s ease-in-out;
  position: absolute;
  left: 20px;
  letter-spacing: 1px;
  top: 10%;
}

.calculator-link {
  display: inline-block;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  color: #ffffff;
  background-color: #0078d7;
  border-radius: 30px;
  letter-spacing: 1px;
  transition: all 0.3s ease-in-out;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.calculator-link:hover {
  background-color: #005bb5;
  color: #ffffff;
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

/* Added smooth transitions and better contrast for modern styling */
              
            
!

JS

              
                const materials = [

  'sound-absorbing', 'heavy', 'weightless', 'liquid', 'reflective', 'corrosive', 'flexible', 'malleable', 

  'stiff', 'flammable', 'fabric', 'styrofoam', 'Vinyl', 'felt', 'wool', 'ceramic', 'plastic', 'aluminum', 

  'steel', 'cast iron', 'digital', 'paper', 'cardboard', 'maple', 'walnut', 'glass', 'gold', 'silver', 

  'bronze', 'brass', 'copper', 'carbon fiber', 'cotton', 'foam', 'rubber', 'silicone', 'canvas', 'concrete', 

  'stone', 'rope', 'wire', 'plywood', 'hair', 'brick', 'leather', 'suede', '3D Printed', 'cork', 'putty', 

  'hemp', 'bamboo', 'dirt', 'twig', 'sheet metal', 'nickel', 'tin', 'zinc', 'balsa wood', 'oak', 'teak', 

  'bone', 'ivory', 'rattan', 'diamond', 'charcoal', 'plaster', 'clay', 'feather', 'floor', 'ceiling', 'wall', 

  'corner', 'papier mâché', 'nylon', 'mercury', 'marble', 'corian', 'glowing', 'floating', 'magnetic', 

  'wood fiber', 'foil', 'porcelain', 'wax', 'underwater', 'outerspace', 'outdoor', 'translucent', 'recyclable', 

  'biodegradable', 'holographic', 'self-healing', 'eco-friendly', 'programmable'

];

const products = [

  'chair', 'stool', 'table', 'mug', 'cup', 'desk lamp', 'floor lamp', 'desk', 'shelf', 'sofa', 'tea cup', 

  'tea pot', 'cutlery', 'chess set', 'lounge', 'alarm clock', 'phone dock', 'keyboard', 'side table', 

  'wallet', 'vase', 'dog bed', 'bird house', 'wine holder', 'skateboard', 'calculator', 'coat hanger', 

  'salt & pepper shaker', 'coasters', 'piggy bank', 'headphones', 'sculpture', 'telephone', 'flashlight', 

  'mail sorter', 'playing cards', 'fan', 'jewelry box', 'mouse', 'lantern', 'walking cane', 'sword', 

  'wall clock', 'mirror', 'bed', 'crib', 'hammock', 'plate', 'bowl', 'coffee mug', 'espresso cup', 

  'glasses', 'fork', 'spoon', 'knife', 'serving tray', 'toy train', 'action figure', 'lamp shade', 

  'cutting board', 'dresser', 'shoe rack', 'rocking chair', 'USB key', '8 ball', 'frying pan', 

  'drawer handle', 'doorknob', 'cable organizer', 'planter pot', 'bottle opener', 'can opener', 'pocket knife', 

  'surfboard', 'shoes', 'book', 'calendar', 'house numbers', 'spice rack', 'suitcase', 'button', 'ring', 

  'baking tray', 'tape dispenser', 'flower pot', 'canoe', 'basket', 'pillow', 'rug', 'wall tile', 'road bike', 

  'bike seat', 'handlebars', 'gaming controller', 'paint brush', 'umbrella', 'toolbox', 'gardening kit', 

  'candle holder', 'decorative jar', 'art piece'

];

$('.random').click(function () {

  const materialElement = $('.material');

  const productElement = $('.object');

  

  // Randomly pick a material and a product

  const randomMaterial = materials[Math.floor(Math.random() * materials.length)];

  const randomProduct = products[Math.floor(Math.random() * products.length)];

  

  // Add animation classes

  materialElement.addClass('opacity');

  productElement.addClass('flipInX');

  // Update text

  materialElement.text(randomMaterial);

  productElement.text(randomProduct);

  // Remove animation classes after animation completes

  setTimeout(() => {

    materialElement.removeClass('opacity');

    productElement.removeClass('flipInX');

  }, 400);

});
              
            
!
999px

Console