123

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.

            
              <figure>
  
  <div class="intro">
  <h1>
    Binge Drinking 
  </h1>
  <h2>
    Do you know the stats?
  </h2>
 
  <nav>
  <button id="play">play</button>
  </nav>
    
  </div>
  
    <div class="question1">
    <p id="first">Which gender reports higher rates of heavy drinking?</p>
    
    <ul id="gender">
      <li id="men">Men</li>
      <li id="women">Women</li>
    </ul>
    </div>  
    
    <div class="answer1">
    <p id="firstanswer">29.9% of men reported at least one heavy drinking day in 2015, compared with 17.4% of women. </p>
    
    <button id="next">Next</button>
    </div>
    
    <div class="question2">
    <p id="second">Which age group reports the highest rates of heavy drinking?</p>
    <ul id="age">
    <li id="young">18-24</li>
    <li id="middle">25-44</li>
    <li id="older">45-64</li>
    <li id="oldest">65+</li>
    </ul>
    </div>
    
    <div class="answer2">  
  <p id="secondanswer">33.2% of adults age 25-44 reported heavy drinking in 2015, compared with 30.1% of adults age 18-24.</p>
      
      <button id="next2">Next</button>
    </div>
    
    <div class="question3">
    <p id="third">Which level of educational attainment is coorelated with higher rates of heavy drinking?</p>
    
    <ul id="edu">
    <li id="hs">High School</li>
    <li id="sc">Some College</li>
    <li id="coll">Bachelor's</li>
    <li id="grad">Master's+</li>
    </ul>
    </div>  

    <div class="answer3">
    <p id="thirdanswer">24.9% of college graduates reported heavy drinking in 2013, compared with 22.2% of high school graduates. </p> 
      
    <button id="next3">Next</button> 
    </div>
    
    <div class="question4">
    <p id="fourth">Which U.S. region reports the highest rates of heavy drinking?</p>
      
    <ul id="region">
    <li id="ne">Northeast</li>
    <li id="mw">Midwest</li>
    <li id="south">South</li>
    <li id="west">West</li>
    </ul>   
    </div>
    
    <div class="answer4">
    <p id="fourthanswer">28.3% of Midwesterners reported binge drinking in 2013, compared with 23.5% of Westerners and 22.9% of Northeasterners.</p>
      
      <button id="end">End</button> 
    </div>
        
  <div class="fin">
    <p id="done">Great job!</p>
  </div> 

</figure>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Abril+Fatface|Nunito+Sans');

*{margin:0;padding:0;}

figure {
  border: 10px double #8c1515;
  width: 414px;
  height: 628px;
  background-color:#efb813;
  position: absolute;
}

h1, h2{
  font-family:'Abril Fatface';
  position:absolute;
}

h1{
  top:150px;
  left:80px;
  font-size:75px;
  color:#06366d;
  text-shadow:#fcef8d 2px 2px;
}

h2{
  top:300px;
  font-size:45px;
  color:#fcef8d;
  text-shadow:#8c1515 2px 2px;
  padding-left:20px;
}

#play{
  border: 10px double #fcef8d;
  color:#fcef8d;
  background-color:#8c1515;
  font-size:35px;
  font-family:'Nunito Sans';
  position:absolute;
  left:160px;
  top:400px;
  padding:5px 5px 5px 5px;
}

#next, #next2, #next3, #end{
  position:relative;
  padding: 5px 5px 5px 5px;
  border: 10px double #8c1515;
  background-color:#fcef8d;
  font-family:'Nunito Sans';
  color:#06366d;
  font-size:25px;
}

#first, #second, #third, #fourth, #firstanswer, #secondanswer, #thirdanswer, #fourthanswer, #done{
  font-family:'Abril Fatface';
  color:#06366d;
  text-shadow:#fcef8d 1px 1px;
  line-height:1.2em;
}

#first, #second, #fourth{
  position:absolute;
  padding:10px 10px 10px 30px;
  top:120px;
  font-size:50px;
}

#third{
  position:absolute;
  padding:10px 10px 10px 30px;
  top:120px;
  font-size:40px;
}

#done{
  position:absolute;
  padding:10px 10px 10px 30px;
  top:250px;
  left:50px;
  font-size:60px;
}

#men, #women, #young, #middle, #older, #oldest, #hs, #sc, #coll, #grad, #ne, #mw, #south, #west{
  position:absolute;
  padding: 5px 5px 5px 5px;
  border: 10px double #8c1515;
  background-color:#fcef8d;
}

#men, #women, #young, #middle, #older, #oldest, #hs, #sc, #coll, #grad, #ne, #mw, #south, #west{
  font-family:'Nunito Sans';
  color:#06366d;
  font-size:25px;
}

#gender{
  display:flex;
  flex-direction:row-reverse;
  justify-content:space-around;
  align-items:center;
  position:relative;
  top:500px;
}

#men{
  left:50px;
  padding:5px 25px 5px 25px;
}

#women{
  right:50px;
}

#firstanswer, #secondanswer, #thirdanswer, #fourthanswer{
  position:absolute;
  color:#06366d;
  padding: 10px 20px 10px 20px;
  top:115px;
}

#firstanswer, #secondanswer, #fourthanswer, #thirdanswer{
  font-size:40px;
}

#next{
  left:160px;
  top:450px;
}

#next2{
  left:160px;
  top:450px;
}

#next3{
  left:160px;
  top:350px;
}

#end{
  left:160px;
  top:340px;
}

#age{
  display:flex;
  flex-flow:row wrap;
  justify-content:space-around;
  align-items:center;
  position:relative;
}

#young{
  top:400px;
  left:50px;
}

#middle{
  top:400px;
  right:50px;
}

#older{
  top:460px;
  left:50px;
}

#oldest{
  top:460px;
  right:50px;
  padding: 5px 18px 5px 20px;
}

#edu{
  display:flex;
  flex-flow:row wrap;
  justify-content:space-around;
  align-items:center;
  position:relative;
}

#hs{
  top:300px;
  left:25px;
}

#sc{
  top:300px;
  right:25px;
}

#coll{
  top:400px;
  left:25px;
  padding: 5px 15px 5px 15px;
}

#grad{
  top:400px;
  right:25px;
  padding: 5px 24px 5px 24px;
}

#region{
  display:flex;
  flex-flow:row wrap;
  justify-content:space-around;
  align-items:center;
  position:relative;
}

#ne{
  top:250px;
  left:50px;
}

#mw{
  top:250px;
  right:50px;
}

#south{
  top:350px;
  left:50px;
  padding: 5px 27px 5px 27px;
}

#west{
  top:350px;
  right:50px;
  padding: 5px 22px 5px 22px;
}

            
          
!
            
              TweenMax.set('#next, .question1,.question2,.question3,.question4, .answer1, .answer2, .answer3, .answer4, #done', {display:'none'});

TweenMax.from('h1', 1, {opacity:0, y:'-=100'});
TweenMax.from('h2', 1, {opacity:0, y:'+=100'});
TweenMax.from('#play', 1, {delay:1, opacity:0, y:'+=100'});

function playGame(){
   TweenMax.set('.question1', {display:'block'});
  TweenMax.to('.intro', .3, {opacity:0});
  TweenMax.staggerFrom('.question1 *', .5, {delay:.5, opacity:0}, .5);
}

$('#play').click(playGame);

function clickMen(){
  TweenMax.to('#men', 2, {backgroundColor:'#158c22',borderColor:'#158c22'}); 
  TweenMax.set('.answer1', {delay:1, display:'block'});
  TweenMax.to('.question1', 1, {delay:1, opacity:0});
  TweenMax.staggerFrom('.answer1 *', 1, {delay:2.3, opacity:0}, .5);
  TweenMax.set('#next', {delay:1, display:'block'});
}

$('#men').click(clickMen);

function clickWomen(){
  TweenMax.to('#women', 1, {backgroundColor:'#8c1515'});
}

$('#women').click(clickWomen);

function clickNext(){
  TweenMax.to('#next',2,{backgroundColor:'#06366d', borderColor:'#06366d'})
  TweenMax.set('.question2', { display:'block'});
  TweenMax.to('.answer1, #next', 1, {delay:1, opacity:0});
  TweenMax.staggerFrom('.question2 *', 1, {delay:2.3, opacity:0}, .5);
}

$('#next').click(clickNext);

function clickYoung(){
  TweenMax.to('#young', 1, {backgroundColor:'#8c1515'});
}

$('#young').click(clickYoung);

function clickOlder(){
  TweenMax.to('#older', 1, {backgroundColor:'#8c1515'});
}

$('#older').click(clickOlder);

function clickOldest(){
  TweenMax.to('#oldest', 1, {backgroundColor:'#8c1515'});
}

$('#oldest').click(clickOldest);

function clickMiddle(){
  TweenMax.to('#middle', 2, {backgroundColor:'#158c22',borderColor:'#158c22'}); 
  TweenMax.set('.answer2', { display:'block'});
  TweenMax.to('.question2', 1, {delay:1, opacity:0});
  TweenMax.staggerFrom('.answer2 *', 1, {delay:2.3, opacity:0}, .5);
  TweenMax.set('#next', {delay:1, display:'block'});
}

$('#middle').click(clickMiddle);

function clickNext2(){
  TweenMax.to('#next2',2,{backgroundColor:'#06366d', borderColor:'#06366d'});
  TweenMax.set('.question3', { display:'block'});
  TweenMax.to('.answer2, #next', 1, {delay:1, opacity:0});
  TweenMax.staggerFrom('.question3 *', 1, {delay:2.3, opacity:0}, .5);
}

$('#next2').click(clickNext2);

function clickHigh(){
  TweenMax.to('#hs', 1, {backgroundColor:'#8c1515'});
}

$('#hs').click(clickHigh);

function clickSome(){
  TweenMax.to('#sc', 1, {backgroundColor:'#8c1515'});
}

$('#sc').click(clickSome);

function clickGrad(){
  TweenMax.to('#grad', 1, {backgroundColor:'#8c1515'});
}

$('#grad').click(clickGrad);

function clickColl(){
  TweenMax.to('#coll', 2, {backgroundColor:'#158c22',borderColor:'#158c22'}); 
  TweenMax.set('.answer3', { display:'block'});
  TweenMax.to('.question3', 1, {delay:1, opacity:0});
  TweenMax.staggerFrom('.answer3 *', 1, {delay:2.3, opacity:0}, .5);
  TweenMax.set('#next', {delay:1, display:'block'});
}

$('#coll').click(clickColl);

function clickNext3(){
  TweenMax.to('#next3',2,{backgroundColor:'#06366d', borderColor:'#06366d'});
  TweenMax.set('.question4', { display:'block'});
  TweenMax.to('.answer3, #next', 1, {delay:1, opacity:0});
  TweenMax.staggerFrom('.question4 *', 1, {delay:2.3, opacity:0}, .5);
}

$('#next3').click(clickNext3);

function clickNorth(){
  TweenMax.to('#ne', 1, {backgroundColor:'#8c1515'});
}

$('#ne').click(clickNorth);

function clickWest(){
  TweenMax.to('#west', 1, {backgroundColor:'#8c1515'});
}

$('#west').click(clickWest);

function clickSouth(){
  TweenMax.to('#south', 1, {backgroundColor:'#8c1515'});
}

$('#south').click(clickSouth);

function clickMidwest(){
  TweenMax.to('#mw', 2, {backgroundColor:'#158c22',borderColor:'#158c22'}); 
  TweenMax.set('.answer4', { display:'block'});
  TweenMax.to('.question4', 1, {delay:1, opacity:0});
  TweenMax.staggerFrom('.answer4 *', 1, {delay:2.3, opacity:0}, .5);
  TweenMax.set('#end', {delay:1, display:'block'});
}

$('#mw').click(clickMidwest);

function clickDone(){
  TweenMax.to('#end',2,{backgroundColor:'#06366d', borderColor:'#06366d'});
  TweenMax.set('#done', {delay:1, display:'block'});
  TweenMax.to('.answer4, #end', 1, {delay:1, opacity:0});
  TweenMax.staggerFrom('#done *', 1, {delay:3.3, opacity:0}, .5);
}

$('#end').click(clickDone);
            
          
!
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.

Console