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 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.

HTML

              
                <audio id="tts"></audio>
<article class="recipe">
  <div class="recipe-image">
    <h1>Chris' Four-Bean Chili</h1>
    <a href="#recipe-text" id="mobile-recipe-anchor"><span class="icon-arrow"></span></a>
  </div>  
  <div class="text-wrapper" id="recipe-text">
    <div class="recipe-text">
      <blockquote>
        My grandpappy used to make this chili over the campfire under the Texas stars. The secret ingredient was a little squeeze of scorpion venom in the pot.
      </blockquote>
      
      <h2>Ingredients</h2>
      <ul>
        <li>
          <input type="checkbox" id="ing-1"/>
          <label for="ing-1"><strong>1lb</strong>
        ground bison</label>
        </li>
        <li>
          <input type="checkbox" id="ing-2"/>
          <label for="ing-2"><strong>1 cup</strong>
        diced onion</label>
        </li>
        <li>
          <input type="checkbox" id="ing-3"/>
          <label for="ing-3"><strong>4</strong>
        diced jalepeñosn</label>
        </li>
        <li>
          <input type="checkbox" id="ing-4"/>
          <label for="ing-4"><strong>1 cup</strong>
        black beans</label>          
        </li>
        <li>
          <input type="checkbox" id="ing-5"/>
          <label for="ing-5"><strong>1 cup</strong>
        great northern beans</label>
        </li>
        <li>
          <input type="checkbox" id="ing-6"/>
          <label for="ing-6"><strong>1 cup</strong>
        kidney beans</label>
        </li>
        <li>
          <input type="checkbox" id="ing-7"/>
          <label for="ing-7"><strong>1 cup</strong>
        pinto beans</label>         
        </li>
        <li>
          <input type="checkbox" id="ing-8"/>
          <label for="ing-8"><strong>4 cloves</strong>
        garlic</label>
        </li>
        <li>
          <input type="checkbox" id="ing-9"/>
          <label for="ing-9"><strong>2 tbsp</strong>
        mexican chili powder</label>
        </li>
        <li>
          <input type="checkbox" id="ing-10"/>
          <label for="ing-10"><strong>2 tsp</strong>
        salt</label>         
        </li>
        <li>
          <input type="checkbox" id="ing-11"/>
          <label for="ing-11"><strong>2 tsp</strong>
        ground pepper</label>          
        </li>
        <li>
          <input type="checkbox" id="ing-12"/>
          <label for="ing-12"><strong>1 tsp</strong>
        cayenne</label>
        </li>
        <li>
          <input type="checkbox" id="ing-13"/>
          <label for="ing-13"><strong>28oz</strong>
        smushed tomatoes</label>          
        </li>
        <li>
          <input type="checkbox" id="ing-14"/>
          <label for="ing-14"><strong>3 cups</strong>
        beef broth</label>          
        </li>
      </ul>
    
      <h2>Directions <a id="speak" href=""></a></h2>      
      <p id="directions">
        Get your filthiest campfire-scorched Dutch oven over the fire the best you can situate it. Brown the bison. Add the diced onion and spices, sautee until soft. Add tomatoes and broth and bring to a simmer for 40 minutes. Add beans and cook another 30 minutes.
      </p>
    </div>
  </div>
</article>
              
            
!

CSS

              
                $full-width: 80em;
$size-mobile-anchor: .75em;
$transparent-black: rgba(0,0,0,.5);
@import url(https://fonts.googleapis.com/css?family=Open+Sans);

*{box-sizing: border-box;margin: 0;padding: 0;}

html,body {
	font-size: 110%;
	line-height: 1.5;
	font-family: 'Open Sans', sans-serif;
	font-weight: 400;
	font-smoothing: antialiased;
  height: 100%;
}

.recipe{
  float: left;
  height: 100%;
  width: 100%;
  
  > * {
    min-height: 100%;
    width: 40%;
    float: left;
    
    @media (max-width: $full-width){
      width: 100%!important;
    }
  }
}

#mobile-recipe-anchor{
  display: none;
  position: absolute;
  padding: .5em;
  bottom: 1em;
  left: 50%;
  margin-left: -1em;
  background-color: $transparent-black;
  text-align: center;
  line-height: $size-mobile-anchor;
  text-decoration: none;
  
  @media (max-width: $full-width){
    display: block;
  }
}

.icon-arrow{
  display: inline-block;
  width: $size-mobile-anchor;
  height: $size-mobile-anchor;
  
  border-right: 3px solid white;
  border-bottom: 3px solid white;
  
  transform: rotateZ(45deg);
}


.recipe-image{
  position: relative;
  width: 60%;
  
  background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/chili.jpg");
  background-repeat: no-repeat;
  background-position: right;
  background-size: cover;
  
  
  @media (min-width: 70em){
    font-size: 2.5em;
  }
  @media (min-width: 50em){
    font-size: 2em;
  }
  font-size: 1.5em;
  
  h1,h2,h3,h4,h5{
    position: absolute;
    top: 50%;
    width: 100%;
    margin: 0;
    transform: translateY(-50%);
    padding: .5em .25em;
    
    background-color: $transparent-black;
    color: white;
    text-align: center;    
  }
}

.text-wrapper{
  padding: 2em 1em;
  
  @media (min-width:$full-width){
    overflow: auto;
    max-height: 100%;
  }
}

ul{
  list-style-type: none;
}

/**/
.recipe-text{
  max-width: 22em;
  margin: auto;
  
  & > h2{
    margin-top: 2.5em;
    margin-bottom: .25em;
  }
}


blockquote {
  background: #f9f9f9;
  margin: 1.5em 5px;
  padding: 0.5em 5px;
  quotes: "\201C""\201D""\2018""\2019";
}
blockquote:before {
  color: #ccc;
  content: open-quote;
  font-size: 4em;
  line-height: 0.1em;
  margin-right: 0.25em;
  vertical-align: -0.4em;
}


// http://www.csscheckbox.com/
input[type=checkbox] {
  position: absolute; 
	overflow: hidden; 
	clip: rect(0 0 0 0); 
	height:1px; 
	width:1px; 
	margin:-1px; 
	padding:0;
	border:0;
}
input[type=checkbox] + label {
  padding-left:20px;
	height:15px; 
	display:inline-block;
	line-height:15px;
	background-repeat:no-repeat;
	background-position: 0 0;
	font-size:15px;
	vertical-align:middle;
	cursor:pointer;
}
input[type=checkbox]:checked + label {
  background-position: 0 -15px;
  
  color:lightgrey;
  text-decoration: line-through;
}
label{
  background-image:url(http://csscheckbox.com/checkboxes/lite-gray-check.png);
}

audio{display: none;}

#speak{
  display: inline-block;
  width: .75em;
  height: .75em;
  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/23249/audio-high.png);
  background-size: 100%;
  opacity: .3;
  
  transition: all .3s ease; 
  
  &:hover{
    opacity: .7;
  }
}
              
            
!

JS

              
                FastClick.attach(document.body);

var $mobileRecipeAnchor = $("#mobile-recipe-anchor"),
    $recipeText = $("#recipe-text"),
    $directions = $("#directions"),
    directions = encodeURIComponent( $directions.html().trim()),
    $tts = document.getElementById("tts"),
    $speak = $("#speak");

$mobileRecipeAnchor.on("click", function(e){
  e.preventDefault();
  $("body").animate({
    scrollTop: $recipeText.offset().top
  });
});


//https://github.com/JosePedroDias/simple-tts/blob/master/static/js/simple-tts-client.js
var supportsMp3 = (function() {
  var aEl = document.createElement('audio');
  return !!(aEl.canPlayType && aEl.canPlayType('audio/mpeg').replace(/no/, ''));
})();



$speak.on("click", function(e){
  if( $tts.currentTime === 0 || $tts.currentTime == $tts.duration){
    var format = supportsMp3 ? 'mp3' : 'ogg';
    $tts.setAttribute("src","http://37.139.20.20:3040/speak/"+directions + "?format=" + format);
    $tts.play();
  }else{
    if( $tts.paused ){
      $tts.play();
    }else{
      $tts.pause();
    }
  }
  e.preventDefault();
});

$(document).on("keydown", function(e){
  if( e.which != 32) return;
  if( $tts.currentTime > 0){
    if( $tts.paused ){
      $tts.play();
    }else{
      $tts.pause();
    }
  }
});
              
            
!
999px

Console