Pen Settings

HTML

CSS

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

JavaScript

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

Behavior

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.

HTML

              
                <div id="projDetails">
  <h1>Contact List App</h1>
  <h2>Menu Works</h2>
  <h2>Settings Works</h2>
  <h2>Add Contact Works</h2>
  <h2>Contact Sum Auto-Calc</h2>
  <h2>Erase DB Works</h2>
</div>
<div class="iphone">
    <div class="power"></div>
    <div class="lock"></div>
    <div class="volume up"></div>
    <div class="volume down"></div>
    <div class="camera"></div>
    <div class="speaker"></div>
    <div class="screen">
      <!-- Put screen stuff in here -->
      
      <div class="wrapper">
        <div class="sidebar">
          <div class="userDetails">
            <h2 class="userName">John Doe
              <h2>
                <p class="userEmail">johndoe@gmail.com</p>
          </div>
          <div class="menu">
            <ul>
              <li class="contacts bold"> Contacts<span id="contactSum"></span></li>
              <li id="settingsButton" class="settings bold">Settings</li>
              <li id="eraseDB" class="eraseDb light"> Erase Database</li>
            </ul>
          </div>
        </div>
        <div id="mainContent" class="content no-animation" data-pos="0">
          <div id="addContact">
            <form>
              <input placeholder="Name"></input>
              <input placeholder="City"></input>
              <input placeholder="State"></input>
              <input placeholder="Phone"></input>
              <button id="addUserInfo">Add User</button>
              <button id="cancelUser">Cancel</button>
            </form>
          </div>
          <div id="settingsMenu">
            Top Header Color: <input class="jscolor" value="2a3f65">
            Contact Card Color: <input class="jscolor" value="ffffff">
            Background Color: <input class="jscolor" value="ffffff">
            <button id="saveSettings">Save Settings</button>
              <button id="cancelSettings">Cancel</button>
          </div>
          <div id="poppedOut">
            <div id="openMenu">
              <span style="float: left; color: white; margin-left: 26px; line-height: 16px">MENU</span>
              <div></div>
              <div></div>
              <div></div>
            </div>
            <div id="searchBar"><i class="fa fa-search"></i> Search by name</div>
          </div>
          <div id="contactList">
          </div>
          <div id="basicMenu">
            <div id="addButton" class="add"><i class="fa fa-3x fa-plus-circle"></i></div>
          </div>
        </div>
      </div>
    </div>
    <div class="button">
      <div class="square"></div>
    </div>
  </div>
              
            
!

CSS

              
                * { box-sizing: border-box; }

html {
  min-height: 1100px;
}
body{
  background:linear-gradient(#014576,#0B7AA7,#4CB1A3,#B1DB91)no-repeat;
  overflow-x: hidden;
}
#projDetails {
  color: white;
  position: absolute;
  h1 { margin-bottom: 50px; }
}
#mainContent {
  overflow: hidden;
  height: 730px;
}
#addContact, #settingsMenu {
  position: absolute;
  width: 100%;
  padding: 0 5%;
  background: rgba(255,255,255,.9);
  bottom: -600px;
  z-index: 999;
  &.active {
    top: 50px;
  }
  input {
    width: 100%;
    height: 40px;
    font-size: 16px;
    transition: 0.6s;
    border: none;
    border-bottom: 1px solid #CCC;
    background-color: transparent;
    margin: 15px 0;
    &:focus {
      outline: none;
      border-bottom: 1px solid #28a2a2;
    }
  }
  button {
    width: 100%;
    border: none;
    height: 50px;
    line-height: 50px;
    color: white;
    font-size: 30px;
    text-transform: uppercase;
    background: #41a041;
    &#cancelUser, &#cancelSettings {
      margin-top: 10px;
      background: #b94848;
    }
  }
}
#settingsMenu {
  padding-top: 50px;
}
.row {
  box-shadow: 0px 2px 15px #ddd; 
  width:180px;
  height:180px;
  float:left;
  margin:5px 10px;
  background:white;
  p {
    font-size:12px;
    width:150px;
    padding:0;
    margin:0;
    font-weight:600;
    color:#a9a9a9;
  }
  h4 {
    font-size:14px;
    width:150px;
  }
  span {
    float:right;
    width:20px;
    position:absolute;
    top:20px;
    left:150px;
  }
}
img{
  border-radius:80px;
  width:80px;
  margin-top:15px;
  margin-left:5px;
}
.fa-star-o{
  color:red;
  cursor:pointer;
}
#basicMenu {
  cursor:pointer;
  width:412px;
  height:50px;
  bottom:0;
   color:#a9a9a9;
  box-shadow: 0px 2px 15px #ddd;
  position:absolute;
  background:white;
}
#basicMenu {
  > div:hover{
    color:#75758a;
  }
  .add{
    margin: 0 auto;
    text-align: center;
    margin-top:4px;
    color:#7394b5;
  }
}

.userDetails {
  h2 {
    font-size:20px;
    color: #09384b;
    padding-top:70px;
  }
  p {
    font-size:13px;
    float:left;
    margin-top:-85px;
    color:#a9a9a9;
  }
}

.menu {
  .bold {
    font-weight:700;
    padding-bottom:10px;
  }
  .light{ 
    font-size:14px;
  }
  .logOut{
    padding-top:60px;
    color:#a9a9a9;
    font-size:18px;
  }
}

.eraseDb{
  padding-top: 40px;
  cursor: pointer;
  &#eraseDB:hover { 
    color: #444;
  }
}
.settings {
  cursor: pointer;
}
.sortView{
  position:relative;
  margin:0 auto;
  width:80px;
   top:20px;
  left:150px;
  cursor:pointer;
}

#contactList {
  margin-top:10px;
  margin-left:5px;
  height: 610px;
  overflow-y: scroll;
  .bold{
    font-weight:700;
    color:#09384b;
  }
}
.gridView, .listView{
  color:#a9a9a9;
  float:right;
  margin:0 5px;
 
}
.wrapper{
  background-color:#fcfcfc;
  display: flex;
  max-height: 736px;
  height: 736px;
  width: 414px;
  margin: 0 auto 10px auto;

  }
.sidebar {
  background:#fcfcfc;
  max-height: 736px;
  height: 736px;
  width: 250px;
  position: absolute;
  padding: 0 50px;
  .menu { 
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: left; 
    ul {
      padding-left: 0;
      li {
        color: #09384b;
        line-height: 3;
        list-style: none;
        font-family: 'Montserrat', sans-serif;
      }
    }
  }
}
.content {
  flex: 1;
  transform: translateX(0) scale(1);
  animation: shrink-off .4s ease-out;
  background: #fcfcfc;
  #searchBar{
    visibility: hidden;
    position:absolute;
    left:130px;
    top:18px;
    border-radius:40px;
    color:#a9a9a9;
  }
  #poppedOut {
    height:50px;
    background: #2a3f65;
  }
  > div { 
    position: relative;
    transition: background-color 0.8s ease; 
  }
  #openMenu { 
    cursor: pointer; 
    position: absolute;
    top: 20px;
    left: 10px;
    > div { 
      width: 20px; 
      border: solid  white 1px;
      margin-bottom: 5px; 
      &:nth-child(2) { width: 15px; }
    }
  }
  &.shrink {
    transform: translateX(250px) scale(.95);
    animation: shrink-on .4s ease-out;
  }
}

.no-animation {
  animation: none !important;
}

@keyframes shrink-on {
  0% { transform: translateX(0) scale(1); }
  70% { transform: translateX(250px) scale(.9); }
  100% { transform: translateX(250px) scale(.95); }
}

@keyframes shrink-off {
  0% { transform: translateX(250px) scale(.95); }
  70% { transform: translateX(-10px) scale(1.05); }
  100% { transform: translateX(0) scale(1); }
}



/*============
*** IPHONE ***
============*/
.iphone {
  position: relative;
  background: #202020;
  width: 460px;
  height: 0;
  padding-top: 920px;
  margin: 0 auto 0 45%;
  border-radius: 3em;
}

.power {
  position: absolute;
  background: #202020;
  width: 13%;
  height: .5%;
  top: -.5%;
  right: 12%;
  border-top-left-radius: .5em;
  border-top-right-radius: .5em;
}

.lock {
  position: absolute;
  background: #202020;
  width: 1%;
  height: 5%;
  top: 12.5%;
  left: -1%;
  border-top-left-radius: .5em;
  border-bottom-left-radius: .5em;
}

.volume {
  position: absolute;
  background: #202020;
  width: 1%;
  height: 4%;
  top: 23%;
  left: -1%;
  border-top-left-radius: .5em;
  border-bottom-left-radius: .5em;
}

.volume.down{ top: 31%; }

.camera {
  position: absolute;
  top: 2%;
  left: 48.5%;
  background: #3f3f3f;
  width: 3%;
  height: 0;
  padding-top: 3%;
  border-radius: 50%;
}

.speaker {
  position: absolute;
  top: 5%;
  left: 42.5%;
  background: #3f3f3f;
  width: 15%;
  height: 0;
  padding-top: 3%;
  border-radius: 1em;
}

.appleicon {
  padding-top: 25%;
  opacity: 0;
  animation: unhide 5s infinite alternate;
}

.appleicon img{
  width: 100%;
  height: 100%;
}

.text {
  opacity: 0;
  font-size: 1.25rem;
  text-align: center;
  animation: unhide 5s infinite alternate;
}

.screen {
  background: #2f2f2f;
  width: 90%;
  height: 80%;
  position: absolute;
  top: 80px;
  left: 5%;
  animation: lighten 5s infinite alternate;
  overflow: hidden;
}

.button {
  position: absolute;
  bottom: 2.75%;
  left: 42.5%;
  background: #3f3f3f;
  /* border: 1px solid #3f3f3f; */
  width: 15%;
  height: 0;
  padding-top: 15%;
  border-radius: 50%;
}

.square {
  position: absolute;
  top: 27.5%;
  left: 27.5%;
  border: 2px solid #d7d7d7;
  border-radius: .3em;
  width: 45%;
  height: 45%;
}

              
            
!

JS

              
                let userSum, userData;

fetch("https://randomuser.me/api/?results=10&nat=US")
      .then(response => response.json())
      .then( users => {
        users = users.results;
        userData = users;
        userSum = users.length;
  
        for (let i=0; i<users.length; i++) {
          let contactRow = document.createElement('div'),
              colBox = document.createElement('div'),
              h4 = document.createElement('h4'),
              location = document.createElement('p'),
              phone = document.createElement('p'),
              image = document.createElement('img');
          
          image.setAttribute('src', users[i].picture.medium);
          h4.innerHTML = `${users[i].name.first} ${users[i].name.last}`;
          location.innerHTML = `${users[i].location.city}, ${users[i].location.state}`
          phone.innerHTML = users[i].cell;
          
          contactRow.classList.add('row');
          colBox.classList.add('col-xs-6');
          
          colBox.appendChild(image);
          colBox.appendChild(h4);
          colBox.appendChild(location);
          colBox.appendChild(phone);
          contactRow.appendChild(colBox);
          
          document.getElementById('contactList').appendChild(contactRow);
        }
});

document.getElementById('openMenu').onclick = e => {
  const container = document.getElementById('mainContent');
  container.classList.remove('no-animation');
  
  document.getElementById('contactSum').innerHTML = ` (${userSum})`
  
  if (container.classList.value.indexOf('shrink') < 0 ) container.classList.add('shrink');
  else container.classList.remove('shrink');
};

document.getElementById('eraseDB').onclick = e => {
  document.getElementById('contactList').innerHTML = '';
};

document.getElementById('addButton').onclick = e => {
  document.getElementById('addContact').classList.add('active');
};

document.getElementById('settingsButton').onclick = e => {
  document.getElementById('mainContent').classList.remove('shrink');
  document.getElementById('settingsMenu').classList.add('active');
  
};

document.getElementById('cancelUser').onclick = e => {
  document.getElementById('addContact').classList.remove('active');
};

document.getElementById('cancelSettings').onclick = e => {
  document.getElementById('settingsMenu').classList.remove('active');
};
              
            
!
999px

Console