JSFiddle - React, Tailwind, and code Playground

by harmonicnw

HTML

<meta name="viewport" content="user-scalable=0, initial-scale=1.0, maxiumum-scale=1.0, width=device-width" />

<div class="wrapper">
    <h1>How To Build a Web App</h1>
    
    <section>
        <h2>Choose a path</h2>
        <div class="content">
            <p>Figure out a problem you want to solve. How is your site going to help somebody?</p>
            <blockquote>
                Two roads diverged in a yellow wood,<br />
                And sorry I could not travel both<br />
                And be one traveler, long I stood<br />
                And looked down one as far as I could<br />	
                To where it bent in the undergrowth;<br /><br />
 
                Then took the other, as just as fair,<br />	
                And having perhaps the better claim,<br />	
                Because it was grassy and wanted wear;	<br />
                Though as for that the passing there<br />	
                Had worn them really about the same,<br /><br />
 
                And both that morning equally lay<br />
                In leaves no step had trodden black.<br />	
                Oh, I kept the first for another day!<br />	
                Yet knowing how way leads on to way,<br />	
                I doubted if I should ever come back.<br /><br />
 
                I shall be telling this with a sigh<br />
                Somewhere ages and ages hence:<br />
                Two roads diverged in a wood, and I—<br />
                I took the one less traveled by,<br />
                And that has made all the difference.<br />
            </blockquote>
        </div>
    </section>
    
    <section>
        <h2>Make sure you have the proper equipment..</h2>
        <div class="content">
            <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Cat_5.jpg/300px-Cat_5.jpg" />
            <img src="http://images.wisegeek.com/cup-of-black-coffee.jpg" />
            <img src="http://static.ddmcdn.com/gif/hammer-1.jpg" />
      ...

CSS

body {
   background: #ddd;
   font-family: "lucida grande", tahoma, sans-serif; 
   font-size: 20px;
   height: 100%;
}
html {
    height: 100%;
}
footer {
    color: gray;
    font-size: 0.8em;
    font-style: italic;
    margin: 1em 0;
    text-align: center;
}
blockquote {
  font-style: italic;
  padding: 0 20px;
  size: 10px;
}
h1 {
    font-size: 1.6em;
    margin: 1em 0;
}
h2 {
    background-position: left center;
    background-repeat: no-repeat;
    cursor: pointer;
    font-size: 1.2em;
    margin: 0.5em 0;
    padding-left: 20px;
}
h2:hover {
    color: rgb(100,100,100);
}
h2.open {
    background-image: url('http://public.harmonicnw.com/tft_2013-02-20/ddarrow-down.png');
}
h2.closed {
    background-image: url('http://public.harmonicnw.com/tft_2013-02-20/ddarrow-right.png');
}
img {
    height: auto;
    margin-bottom: 1em;
    width: 100%;
}
p {
    margin: 1em 0;
}

section {
    background: rgb(255,238,178);
    border-radius: 5px;
    margin: 5px 0;
    padding: 5px 3%;
    width: 94%;
}

.wrapper {
    background: white;
    height: 100%;
    margin: 0 auto;
    overflow-y: auto;
    padding: 0 3%;
    width: 90%;
}

JavaScript

$(document).ready( function() {
   
    $(".wrapper").fitVids();
    
    $("section").each( function(i) {
        var content = $(this).children(".content");
        var hdr =  $(this).children("h2");
        hdr.text(i+1 + ". " + hdr.text());
        hdr.click( function(e) {
            if (content.is(":visible")) {
                content.slideUp();
                hdr.removeClass("open").addClass("closed");
            } else {
                $("section").children(".content:visible").slideUp();
                $("section").children("h2").removeClass("open").addClass("closed");
                content.slideDown();
                hdr.removeClass("closed").addClass("open");
            }
            e.preventDefault();
            $(this).blur();
        });
        content.hide();
        hdr.addClass("closed");
    });
    
});