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 id='content'>
  <h6 id='heading'>Mida täna õhtul süüa?</h6>
  <button id='mainbutton' onClick='generateIdea()'>Ütle mulle!</button>
    <div id='name'>
      // TODO: implement this before boss fires me!!!1!!1
    </div>
    <img id='image' src='https://ounapuu.ee/posts/2023/12/19/spicy-usb-adapter/media/cats.jpg'>
</div>
              
            
!

CSS

              
                #content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: Arial, Helvetica, sans-serif;
  background-image: url('https://flat-icons.com/wp-content/uploads/2021/03/Graphic-Design-Is-My-Passion.jpg');
  height: 100vh;
}

button {
  background-color: #04AA3D;
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 24px;
  cursor:pointer;
}

button:hover {
  background-color: white;
}

#name {
  margin: 25px;
}

#image {
  max-width: 300px;
  max-height: 300px;
  margin: 30px;
}

.australianmode {
    transform: rotate(180deg) scale(1.4);
}
              
            
!

JS

              
                var foods = [
  {name: "Riis kanaga", imageLink: "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Fried_chicken_thighs_with_rice.jpg/1200px-Fried_chicken_thighs_with_rice.jpg"},
  {name: "Kartul ja hakklihakaste", imageLnk: "https://nami-nami.ee/files/recipes/380/hakklihakaste.jpg"},
  {name: "Spaghetti Bolognese", imageLink: "https://upload.wikimedia.org/wikipedia/commons/2/25/SushiMaki.jpg"},
  {name: "telli midagi Hesburgerist lihtsalt", imageLink: ""}
]

function generateIdea() {
  var randomIdea = getRandomElement(foods);
  document.getElementById("name").innerHTML = randomIdea.name;
  document.getElementById("image").classList.add('australianmode')
  document.getElementById("image").src = randomIdea.imageLink;
}

function getRandomElement(listOfItems) {
  return listOfItems[Math.floor(Math.random()*listOfItems.length)]
}
              
            
!
999px

Console