cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <h1>
  <div>The Top Three...</div>
  <div class="subhead">Breakfast Foods</div>
</h1>
<div class="wrapper">
  <div class="panel">
        <div class="learn-more learn-more--hidden">
      <button class="learn-more-header">
        Close
      </button>
      <div class="details-text">
        <p>Bacon is the cornerstone of any great breakfast or brunch.  You can take it crispy and black or so raw it's still flopping around and squealing on your plate.  Doesn't matter to me- it's still good!</p>
        <p>
          There are so many varieties to choose from: from the traditional Oscar Meyer to Black Pepper or even Maple Cured.  Pick one and get to frying...
        </p>
        <img src="https://img.webmd.com/dtmcms/live/webmd/consumer_assets/site_images/article_thumbnails/quizzes/bacon_sizzling_facts_rmq/650x350_bacon_sizzling_facts_rmq.jpg" alt="bacon!"/>
          </div>
    </div>
    <h3>Bacon</h3>
    <button class="show-on-hover">Learn More</button>
  </div>
  <div class="panel grow">
        <div class="learn-more learn-more--hidden">
      <button class="learn-more-header">
        Close
      </button>
          <div class="details-text">
      <p>The versatile and delicious egg.  Like her sibling, bacon (see adjacent slide), she can be prepared many different ways.  Many a breakfast table battle has broken out over the merits of scrambling vs sunny side up.</p>
            <p>But we're not here to fight battles, we're here to make lists.  Scrambled gets the nod because of it's versatility- throw in some cheese or onions, or sausage if you lean toward the carinverous side, and you've got a full on meal!</p>
            <img src="http://assets.marthastewart.com/styles/wmax-520-highdpi/d20/scrambled_eggs_101_1/scrambled_eggs_101_1_vert.jpg?itok=7zMWwqtb" alt="eggs!" />
          </div>
    </div>
    <h3>Scrambled Eggs</h3>
    <button class="show-on-hover">Learn More</button>
  </div>
  <div class="panel">
        <div class="learn-more learn-more--hidden">
      <button class="learn-more-header">
        Close
      </button>
          <div class="details-text">
      <p>I know- this one's cheating a bit, but this is my list, so I get to do what I want.  The breakfast burrito is the ultimate utility player in your first meal lineup.  Throw in some potatoes and tofu and you're a vegetarian.  Use chorizo and salsa and you've got a traditional burrito</p>
            <p>Don't plan on doing anything but going right back to sleepy town after devouring a breakfast burrito, but hey- it's worth it!</p>
            <img src="http://foodnetwork.sndimg.com/content/dam/images/food/fullset/2013/2/14/0/FNK_breakfast-burrito_s4x3.jpg.rend.sniipadlarge.jpeg" alt="burrito" />
          </div>
    </div>
    <h3>Breakfast Burrito</h3>
    <button class="show-on-hover">Learn More</button>
  </div>
<!--   <div class="panel">
        <div class="learn-more learn-more--hidden">
      <button class="learn-more-header">
        Close
      </button>
          <div class="details-text">
      This is the details area
          </div>
    </div>
    <h3>Four</h3>
    <button class="show-on-hover">Learn More</button>
  </div>
  <div class="panel">
    <div class="learn-more learn-more--hidden">
      <button class="learn-more-header">
        Close
      </button>
      <div class="details-text">
      This is the details area
      </div>
    </div>
    <h3>Five</h3>
    <button class="show-on-hover">Learn More</button>
  </div> -->
</div>


            
          
!
            
              * {
  box-sizing: border-box;
  font-family: 'Roboto', sans-serif;
}
html, body {
  height: 100%;
  min-height 100%;
  background-image: url('https://images.unsplash.com/photo-1474433188271-d3f339f41911?dpr=1.5&auto=format&fit=crop&w=1500&h=NaN&q=80&cs=tinysrgb&crop=');
  background-size: cover;
}
h1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: normal;
  position: absolute;
  z-index: 99;
  background-color: #333;
  width: 100%;
  margin: 0;
  padding: 3px 9px 3px 9px;
  color: #ccc;
  height: 10vh;
  box-shadow: 0 0 3px #000;
}
.subhead {
  font-family: 'Great Vibes';
}
h3 {
  font-weight: normal;
}
.wrapper {
  display: flex;
  justify-content: space-between;
  height: 100vh;
  overflow: hidden;
}
.panel {
  position: relative;
  width: 33%;
  height: 90vh;
  margin-top: 10vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: width 0.5s cubic-bezier(0.6, 0, 0.3, 1);
}
.grow {
  width: 60%;
}
.shrink {
  width: 20%;
}

.show-on-hover {
  border: 0;
  background-color: #333;
  color: #ccc;
  padding: 6px;
  outline: 0;
  border-radius: 3px;
  transform: scale(0);
  transition: transform 0.3s cubic-bezier(0.6, 0, 0.3, 1);
  cursor: pointer;
}
.show-on-hover--show {
  transform: scale(1);
}

.learn-more {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255,255,255,1);
  transition: transform 0.3s cubic-bezier(0.42, 0, 0.5, 0.8);
  z-index: 99;
}
.learn-more--hidden {
  transform: translateY(100%);
}
.learn-more-header {
  top: 0;
  left: 0;
  width: 100%;
  border: 0;
  padding: 3px;
  box-shadow: 0 1px 3px 0 #333;
  margin-bottom: 6px;
  cursor: pointer;
}
.learn-more-header:hover {
  box-shadow: 0 0 6px 1px #333;
}
.details-text {
  padding: 6px;
  overflow-y: auto;
}
.details-text img {
  width: 100%;
}

@media(max-width: 600px) {
  .wrapper {
    flex-direction: column;
  }
  h1 {
    flex-direction: column;
    justify-content: space-around;
    font-size: 16pt;
  }
  .subhead {
    font-size: 12pt;
  }
  .panel {
    width: 100%;
    height: 30vh;
    transition: height 0.5s cubic-bezier(0.6, 0, 0.3, 1);
  }
  .grow {
    width: 100%;
    height: 80vh;
  }
  .shrink {
    width: 100%;
    height: 10vh;
  }
  .learn-more {
    position: fixed;
    height: 100vh;
  }
  .learn-more--hidden {
    transform: translateX(100%);
  }
}
            
          
!
            
              const init = function() {
  const colors = [
    {id: 'one-a', main: '#8E2800', accent: '#B64926', text: '#fff'}, 
    {id: 'one-b', main: '#468966', accent: '#FFB03B', text: '#FFF0A5'},
    {id: 'two-a', main: '#2C3E50', accent: '#2980B9', text: '#fff'},
    {id: 'two-b', main: '#E74C3C', accent: '#3498DB', text: '#ECF0F1'},
    {id: 'three-a', main: '#962D3E', accent: '#979C9C', text: '#F2EBC7'},
    {id: 'three-b', main: '#343642', accent: '#348899', text: '#F2EBC7'},
    {id: 'four-a', main: '#405952', accent: '#9C9B7A', text: '#FFD393'},
    {id: 'four-b', main: '#F54F29', accent: '#FF974F', text: '#FFD393'}
  ];
  let usedColors = [];
  const panels = document.querySelectorAll('.panel');
  
  //initialize panel colors and click handler
  panels.forEach(panel => {
    let color = getColor();
    
    let details = panel.querySelector('.show-on-hover');
    let showMore = panel.querySelector('.learn-more');
    let close = panel.querySelector('.learn-more-header');
    
    panel.style.backgroundColor = color.main;
    panel.style.color = color.text;
    showMore.style.backgroundColor = color.accent;
    close.style.backgroundColor = color.main;
    close.style.color = color.text;
    details.addEventListener('click', function() {
          showMore.classList.remove('learn-more--hidden');
        }, false);
    close.addEventListener('click', function() {
      showMore.classList.add('learn-more--hidden');
    })
    panel.addEventListener('mouseover', slide, false);
    panel.addEventListener('mouseleave', function() {
      showMore.classList.add('learn-more--hidden');
    }, false);
  });  
  
  function getColor() {
    let color = colors[random(0, colors.length)];
    while(usedColors.indexOf(color.id) !== -1) {
      color = colors[random(0, colors.length)];
    }
    usedColors.push(color.id);
    return color;
  }
  
  function slide() {    
    panels.forEach(panel => {
      let myDetails = panel.querySelector('.show-on-hover');
      if(this === panel) {
        this.classList.remove('shrink');
        this.classList.add('grow');
        myDetails.classList.add('show-on-hover--show');
      } else {
        panel.classList.remove('grow');
        panel.classList.add('shrink');
        myDetails.classList.remove('show-on-hover--show');
      }
    });
  }
  
  function random(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min)) + min;
  }
}

document.addEventListener('DOMContentLoaded', init, false);
            
          
!
999px
Loading ..................

Console