css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="background--path"></div>
  <h1 class="m-t-0 m-b-30">Trip Idea Generator <span class="version">v1.0</span></h1>

  <button id="trigger" class="button m-b-50">Get another trip idea</button>

  <div id="idea-container" class="trip-idea__container m-b-20">
    <div id="place-image" class="trip-idea-image m-b-30"></div>
    <div class="d-inline-block m-b-20 p-x-15">
      <p class="trip-label">What</p>
      <p id="activity" class="trip-value">Getting lost</p>
    </div>
    <div class="d-inline-block m-b-30 p-x-15">
      <p class="trip-label">Where</p>
      <p id="place" class="trip-value">Paris, France</p>
    </div>    
  </div>

  <div class="attribution m-b-100">
    <p>👏 Thanks for the photo,
      <a class="attr-link" id="photographer-link" href="https://unsplash.com/@yokeboy" target="_blank">
        <span id="photographer">Yeo Khee</span>
      </a>
    </p>
  </div> 

  <p>&copy; 2018 <a class="attr-link" href="http://adamruf.com" target="_blank">Adam Ruf</a> for <a class="attr-link" href="http://uxdesigncontest.com" target="_blank">UX Design Contest #6</a></p>

  <script src="app.js"></script>
            
          
!
            
              * {
  margin: 0;
}

body {
  background: rgb(255,255,187);
  background: linear-gradient(160deg, rgba(255,255,187,1) 0%, rgba(255,212,224,1) 100%) center center fixed;
  color: rgba(31,33,39,0.6);
  font-family: Montserrat, Helvetica Neue, Tahoma, sans-serif;
  font-weight: 400;
  padding: 20px;
  padding-top: 100px;
  text-align: center;
  z-index: -2;
}

.background--path {
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/path.svg') left center;
  background-size: contain;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  opacity: 0.5;
  z-index: -1;

}

h1 {
  color: rgba(31,33,39,0.6);
  font-size: 50px;
  font-weight: 400;
  line-height: 1.1;
}

.m-b-20 { margin-bottom: 20px !important; }

.m-b-30 { margin-bottom: 30px !important; }

.m-b-50 { margin-bottom: 50px !important; }

.m-b-100 { margin-bottom: 100px !important; }

.m-r-30 { margin-right: 30px !important; }

.m-t-0 { margin-top: 0 !important;}

.p-x-15 {
  padding-left: 15px;
  padding-right: 15px;
}

.version {
  font-size: 30px;
}

.button {
  background: #1F2127;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.11), 0 4px 6px rgba(0,0,0,0.08);
  font-family: Montserrat;
  font-size: 25px;
  font-weight: 400;
  color: white;
  padding: 12px 20px;
  text-transform: uppercase;
  transform: translateY(0);
  transition: all 0.3s ease-in-out;
}

@media screen and (max-width: 529px) {
  .button {
    font-size: 20px;
  }
}

.button:hover {
  box-shadow: 0 3px 5px rgba(0,0,0,0.09), 0 7px 10px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}

.button:active,
.button:active:focus {
  box-shadow: 0 1px 3px rgba(0,0,0,0.11), 0 4px 6px rgba(0,0,0,0.08);
  transform: translateY(2px);
}

.button:focus {
  outline: none !important;
  box-shadow: 0 0 50px rgba(255,212,224,1), 0 3px 5px rgba(0,0,0,0.09), 0 7px 10px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}

.trip-idea__container {
  background: white;
  border-radius: 10px;
  box-shadow: 0 3px 5px rgba(0,0,0,0.11), 0 5px 10px rgba(0,0,0,0.08);
  margin: 0 auto;
  min-height: 400px;
  max-width: 600px;
}

.trip-idea-image {
  background: #ECF4F9;
  background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/paris%402x.jpg');
  background-position-y: center;
  background-size: cover;
  border-radius: 10px 10px 0 0;
  height: 250px;
  max-width: 600px;
}

.trip-label {
  font-size: 16px;
  text-transform: uppercase;
}

.trip-value {
  color: #1F2127;
  font-size: 25px;
  font-weight: 700;
  text-transform: capitalize;
}

.d-inline-block {
  display: inline-block;
}

.attribution {
  background: rgba(255,255,255,0.5);
  border-radius: 50px;
  margin: 0 auto;
  max-width: 380px;
  padding: 12px 26px;
}

.attr-link {
  color: rgba(31,33,39,0.6);
  text-decoration: underline;
}

.attr-link:hover,
.attr-link:active,
.attr-link:focus {
  color: rgb(31,33,39);
}

            
          
!
            
              // Create an Array of activities
var activities = ["birdwatching", "detectoring", "skydiving", "museum hopping", "gallery hopping", "sightseeing", "dog walking", "juggling", "orienteering", "treasure hunting"];

// Create an Array of Objects of location-related information
var place = [];
place[0] = { place:"Seville, Spain", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/seville%402x.jpg')", photographer:"Henrique Ferreira", photographerLink:"https://unsplash.com/@rickpsd" };
place[1] = { place:"Detroit, USA", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/detroit%402x.jpg')", photographer:"Doug Zuba", photographerLink:"https://unsplash.com/@thezuba" };
place[2] = { place:"Canberra, Australia", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/canberra%402x.jpg')", photographer:"Social Estate", photographerLink:"https://unsplash.com/@socialestate" };
place[3] = { place:"Hamburg, Germany", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/hamburg%402x.jpg')", photographer:"Patrick Baum", photographerLink:"https://unsplash.com/@gecko81de" };
place[4] = { place:"Kaohsiung, Taiwan", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/kaohsiung%402x.jpg", photographer:"Dominik Vanyi", photographerLink:"https://unsplash.com/@dominik_photography" };
place[5] = { place:"Antwerp, Belgium", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/antwerp%402x.jpg", photographer:"Kristaps Grundsteins", photographerLink:"https://unsplash.com/@grundsteins" };
place[6] = { place:"Matera, Italy", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/matera%402x.jpg')", photographer:"carlo testa", photographerLink:"https://unsplash.com/@cha" };
place[7] = { place:"San Juan, Puerto Rico", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/sanjuan%402x.jpg')", photographer:"Cristian Escobar", photographerLink:"https://unsplash.com/@cristian1" };
place[8] = { place:"Guanajuato, Mexico", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/guanajuato%402x.jpg')", photographer:"Alfonso Navarro", photographerLink:"https://unsplash.com/@poncho_nj" };
place[9] = { place:"Oslo, Norway", photo:"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/94276/oslo%402x.jpg')", photographer:"Vidar Nordli-Mathisen", photographerLink:"https://unsplash.com/@vidarnm" };


// Create a function to call when someone clicks the button
function randomTripIdea() {

  // Randomly select an activity and assign the value to a variable
  var randActivity = activities[Math.floor(Math.random() * activities.length)];

  // Randomly select a place and assign the value to a variable
  var randPlace = place[Math.floor(Math.random() * place.length)];

  // Blur the current trip idea
  document.getElementById('idea-container').style.filter = "blur(5px)";

  // Insert randomly selected activity
  document.getElementById('activity').innerHTML = randActivity;

  // Insert the location name
  document.getElementById('place').innerHTML = randPlace.place;

  // Insert the location photo
  document.getElementById('place-image').style.backgroundImage = randPlace.photo;

  // Insert the photographer name
  document.getElementById('photographer').innerHTML = randPlace.photographer;

  // Insert the photographer link
  document.getElementById('photographer-link').href = randPlace.photographerLink;

  // Remove blur filter
  document.getElementById('idea-container').removeAttribute("style");

}

// Set up the button to run the random-selection function
document.getElementById("trigger").onclick = function() { randomTripIdea() };
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console