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="hero">
  <div class="hero-inner">
    <h1>Cats Are Awesome!</h1>
    <h2><span id="count">100</span> of people agree</h2>
    <button id="agree" class="btn" onclick="agree()">I agree</button>
  </div>
</div>
<div class="section">
  <h2>About Me</h2>
</div>
<div class="about">
  <div class="outer">
    <div class="column">
      <img src="https://images.unsplash.com/photo-1568977805153-e0a2d26da0e0" alt="Chell" />
    </div>
    <div class="column">
      <p>Hi, my name is Chell! </p>
      <br />
      <p> I am a beautiful tortie/calico/tabby cat. I have been named Peoples choice of the household since the day I blessed this home.</p>
      <br />
      <p> However, I am not happy. And why would such a beautiful cat like me not be happy? Well, I have the answer.</p>
      <br /><strong>THE DOG.</strong></p>
      <br />
      <p>Ever since my mom brought home the dog (named Leela) life has been subpar. The dog always wants to smell things, play, and be a good girl overall. Honestly how lame! Also, I've caught her I few times trying to eat from the litter box. Disgusting!</p>
      <br />
      <p>So I created this site to celebrate how wonderful cats are, and how dogs are not wonderful.</p>
    </div>
  </div>
</div>
<div class="section">
  <h2>Learn More</h2>
</div>
<div class="learn-more">
  <p>Have dogs ruined your life too? Well maybe you can find comfort here.</p>
  <div class="outer">
    <div class="column">
      <div class="container">
        <a href="#fact" onClick="getCatFact()">
          <img src="https://images.unsplash.com/photo-1580784355694-0d5295dcc007?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0MjU4OTA&ixlib=rb-4.0.3&q=80" class="image" alt="Cat" />
        </a>
        <div class="text">
          <h2>Cat Facts</h2>
        </div>
      </div>
    </div>
    <div class="column">
      <div class="container">
        <a href="#fact" onClick="getDogFact()">
          <img src="https://images.unsplash.com/photo-1601880348117-25c1127a95df?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0MjU5MzI&ixlib=rb-4.0.3&q=80" class="image" alt="Dog" />
        </a>
        <div class="text">
          <h2>Dog Facts</h2>
        </div>
      </div>
    </div>
  </div>
	<div class = "fact">
    <h2>Click the images above to get a cat/dog fact!</h2>
		<img id="image" src="https://images.unsplash.com/photo-1549545931-59bf067af9ab?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0Mjk0ODk&ixlib=rb-4.0.3&q=80"/>
		<p><span id="fact"></span></p>
	</div>
</div>
<div class="footer">
  <div class="outer">
    <p>This site is created for cat lovers. Haters are not welcome.</p>
    <p><strong>Note:</strong> This site was created for me by my mother, as I still lack the ability to type. My mother would like to say she made this under duress, and does not share my view on hating dogs. She APPARENTLY likes all animals.</p>
  </div>
</div>
              
            
!

CSS

              
                body {
  margin: 0;

  /* Font */
  font-family: sans-serif;
}

p {
  font-family: sans-serif;
}

.hero {
  /* Sizing */
  width: 100vw;
  height: 100vh;

  /* Flexbox stuff */
  display: flex;
  justify-content: center;
  align-items: center;

  /* Text styles */
  text-align: center;

  /* Background styles */
  background-image: url("https://images.unsplash.com/photo-1596854372407-baba7fef6e51?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0MjYwMzg&ixlib=rb-4.0.3&q=80");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.hero h1 {
  /* Text styles */
  font-size: 5em;

  /* Margins */
  margin-top: 0;
  margin-bottom: 0.5em;
}

.hero h2 {
  /* Text styles */
  font-size: 2em;

  /* Margins */
  margin-top: 0;
  margin-bottom: 0.5em;
  opacity: 1;
}

.hero .btn {
  /* Font */
  font-family: sans-serif;

  /* Positioning and sizing */
  display: block;
  width: 200px;

  /* Padding and margins */
  padding: 1em;
  margin-top: 50px;
  margin-left: auto;
  margin-right: auto;

  /* Text styles */
  color: black;
  text-decoration: none;
  font-size: 1.5em;

  /* Border styles */
  border: 2px solid black;
  border-radius: 20px;

  /* Background styles */
  background-color: rgba(147, 112, 219, 0.5);
}

.section {
  background-color: black;

  /* Text styles */
  text-align: center;
  color: rgb(147, 112, 219);

  /* Padding */
  padding-top: 25px;
  padding-bottom: 25px;
}

.section h2 {
  /* Text styles */
  font-size: 2em;
}

.about {
  background-color: rgb(153, 204, 255);
  text-align: center;

  /* Padding */
  padding-top: 25px;
  padding-bottom: 25px;
  overflow: hidden; /* make sure this doesn't cause unexpected behaviour */
}

.about .outer {
  width: 60%;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

/* About image*/
.about img {
  margin: auto;
  width: 100%;
  padding: 20px;
  border-radius: 50%;
  width: 300px;
  height: 300px;
  object-fit: cover;
}

/* Create two equal columns that floats next to each other */
.about .column {
  float: left;
  width: 50%;
}

.learn-more {
  background-color: rgb(153, 204, 255);
  text-align: center;

  /* Padding */
  padding-top: 25px;
  padding-bottom: 25px;
  overflow: hidden; /* make sure this doesn't cause unexpected behaviour */
}

.learn-more .outer {
  width: 60%;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.learn-more .column {
  float: left;
  width: 50%;
}

/* Learn more image*/
.learn-more .image {
  margin: auto;
  width: 100%;
  padding: 20px;
  border-radius: 50%;
  width: 300px;
  height: 300px;
  object-fit: cover;
}

.container {
  position: relative;
}
.container .text {
  color: white;
  position: absolute;
  z-index: 999;
  margin: 0 auto;
  left: 0;
  right: 0;
  text-align: center;
  top: 60%;
  width: 60%;
}

/* Learn more hover*/
.learn-more .column:hover .image {
  /* Background styles */
  opacity: 0.3;
}
/* Learn more hover*/
.learn-more .column:hover .text {
  color: black;
}

.fact {
  background-color: rgba(147, 112, 219, 0.5);
  width: 60%;
  margin: 0 auto;
  align-items: center;
  text-align: center;

  /* Padding */
  padding-top: 25px;
  padding-bottom: 25px;
  overflow: hidden; /* make sure this doesn't cause unexpected behaviour */
}

/* Fact image*/
.fact img {
  margin: auto;
  width: 100%;
  padding: 20px;
  max-width: 500px;
  max-height: 500px;
  width: auto;
  height: auto;
}

.footer {
  text-align: center;
  background: black;
  color: rgb(147, 112, 219);

  /* Padding */
  padding-top: 25px;
  padding-bottom: 25px;
  overflow: hidden; /* make sure this doesn't cause unexpected behaviour */
}

.footer .outer {
  width: 60%;
  margin: 0 auto;
  align-items: center;
}

              
            
!

JS

              
                async function agree() {
  document.getElementById("count").innerText++;
}

async function getCatFact() {
  const factlist = [
    ["Use sustainable energy to stay warm.", "https://images.unsplash.com/photo-1570579445398-1c555074dff6?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0Mjk1OTg&ixlib=rb-4.0.3&q=80"],
    [
      "Cats are resourceful, we can make anything a bed",
      "https://images.unsplash.com/photo-1587045311651-a84c727f0ecd?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0Mjk2NTY&ixlib=rb-4.0.3&q=80"
    ],
    ["Cats can make themselves compact.", "https://github.com/chaotictoejam/CTS2375-Example-Final-Project/blob/master/example-1/images/chell_ball.jpg?raw=true"],
    ["Can climb up high", "https://images.unsplash.com/photo-1610016144621-a0b3cd5addd8?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0Mjk3NzI&ixlib=rb-4.0.3&q=80"],
    ["Cats know how to use a bed.", "https://images.unsplash.com/photo-1513977055326-8ae6272d90a7?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0Mjk3OTk&ixlib=rb-4.0.3&q=80"],
    ["Cats are perfect.", "https://images.unsplash.com/photo-1516750105099-4b8a83e217ee?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0Mjk4MTY&ixlib=rb-4.0.3&q=80"]
  ];
  let randomFact = factlist[Math.floor(Math.random() * factlist.length)];
  document.getElementById("fact").innerHTML = randomFact[0];
  document.getElementById("image").src = randomFact[1];
}

async function getDogFact() {
  const factlist = [["Dogs like to play in water!", "https://images.unsplash.com/photo-1505623547966-8af2af3515ac?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0Mjg5NTc&ixlib=rb-4.0.3&q=80"], 
        ["Dogs don't understand beds are for sleeping.", "https://images.unsplash.com/photo-1553736026-ff14d158d222?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0Mjg5ODQ&ixlib=rb-4.0.3&q=80"],  
        ["Dogs destroy their toys", "https://images.unsplash.com/photo-1588218955664-d18f4e3056e5?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0MjkwNzA&ixlib=rb-4.0.3&q=80"],  
        ["Wear sweaters. Seriously? You have fur.", "https://images.unsplash.com/photo-1611653100849-fd8325cada0a?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0MjkwODg&ixlib=rb-4.0.3&q=80"],  
        ["Attack the broom.", "https://github.com/chaotictoejam/CTS2375-Example-Final-Project/blob/master/example-1/images/leela_broom.gif?raw=true"],  
        ["Like to play in dirt.", "https://images.unsplash.com/photo-1626018743149-427a9e2821ed?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzI0MjkxNjI&ixlib=rb-4.0.3&q=80"]
    ];
  let randomFact = factlist[Math.floor(Math.random() * factlist.length)];
  document.getElementById("fact").innerHTML = randomFact[0];
  document.getElementById("image").src = randomFact[1];
}

              
            
!
999px

Console