Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                <div class="container" id='wrap'>
  <img id="duck" src="" alt="duck" />
  <div class="scoreContainer">
    <div id="score-text">Score</div>
    <div id="score-counter">0</div>


  width: 100%;
  height: 100vh;
  background-image: url('');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: 50%  50%;
  overflow: hidden;
  position: relative;

/*Set a fixed size for width and height and in an absolute position*/
#duck {
  margin: 50px;
  width: 70px;
  height: 70px;
  position: absolute;
  left: 100px;
  top: 100px;
  cursor: pointer;
  z-index: 2;
/*Style for the Score container*/
.scoreContainer {
  background-color: black;
  width: 15%;
  color: #ffffff;
  top: 5%;
  right: 5%;
  border: 2px solid greenyellow;
  border-radius: 10px;
  display: flex;
  position: fixed;
  flex-direction: column;
  align-items: center;
#score-text {
  font-size: 1.5em;
#score-counter {
  font-size: 3.1em;
  font-weight: bold;
  color: #06e515;


                //Get the target element
const duck = document.querySelector("#duck"),
      wrap = document.querySelector('#wrap');
let count = 0;

duck.addEventListener("click", () => {

//Increase score by 1
const increaseScore = () => {
  const score = document.querySelector("#score-counter");

  count ++;
  score.textContent = count;

//Move the duck randomly 
const moveDuck = () => {
  let wrapWidth = wrap.clientWidth;
  let wrapHeight = wrap.clientHeight; = Math.floor((Math.random() * wrapWidth - 70)) + "px"; = Math.floor((Math.random() * wrapHeight - 70)) + "px";