Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.


                <div class = "container">
  <h2>Treehouse Badges by Category</h2>
  <div id = "badges"></div>


                li,ul,img {
  margin: 0;
  padding: 0;

.container {
  width: 600px;
  margin: 20px auto;

h2 { width: 500px; margin: 50px 50px; }
#badges { width: 400px; margin: auto;}

/* number of badges per line, the formula is ((2 * X)n + (X + 1)) so for 6 per line that's 12n+7, math magic from */
.container li:nth-child(6n + 4) {
  margin-left: 55px;

li {
  position: relative;
  list-style-type: none;
  display: inline-block;
  width: 100px;
  margin-right: 5px;
  margin-top: -25px;

img { width: 100px; }
img:hover {
  position: relative;
  z-index: 2;
  transform: scale(1.5);

/********** tooltips  **********/
/* CSS tooltips based on:*/

li span { display: none; }
li > img:hover + span {
  display: block;
  z-index: 3;
  position: absolute;
  top: 15px;
  left: -160px;
  width: 150px;
  padding: 3px;
  background-color: #ddd; 
  /* CSS3 finishing touches */
  border-radius: 4px;
  background-image: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
  box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;

/****** little triangle on the tooltip *****/
li span:before,li span:after {
  content: "";
  z-index: 4;
  position: absolute;
  top: 5px;
  right: -7px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid #ddd;


                $(document).ready(function() {
  var user = "jamesbarnett"; /* treehouse username*/
  /* Treehouse categories: Websites,Programming,Business,iOS Development,Android Development*/
  var category = "Programming"; 

  $.getJSON("" + user + ".json", function(data) {
    var output = "<ul>";
    for (i = data.badges.length - 1; i > 0; i--) {
      if ((data.badges[i].courses[0] !== undefined) && (data.badges[i].courses[0].title === category)) {
        output += '<li>';
        output += '<img src ="' + data.badges[i].icon_url + '" />';
        output += '<span>' + data.badges[i].name  +  '</span>';
        output += "</li>";
    output += "</ul>";
    document.getElementById("badges").innerHTML = output;