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

              
                <div class="container text-center">
  <div class="row">
    <div class="main col-sm-6 col-sm-offset-3">
      <div id="random" class="section">
        <a class="btn btn-info btn-lg btn-block" href="https://en.wikipedia.org/wiki/Special:Random">Find a random article</a>
      </div>
      <div id="search" class="section">
        <form id="searchForm" method="">
          <button type="reset" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <input id="searchBar" type="text" class="form-control input-lg text-center" placeholder="Search for an article on Wikipedia">
        </form>
      </div>
      <div id="searchButton" class="section">
        <button type="submit" form="searchForm" class="btn btn-success btn-lg btn-block">Click here or press Enter</button>
      </div>
      <div id="results" class="section">
        <!-- This is where the results will append -->
      </div>
    </div>
  </div>
</div>
<div id="credits">
  &copy; 2016 <a href="https://www.freecodecamp.com/queennectarine">QueenNectarine</a>
</div>
              
            
!

CSS

              
                html {
  min-height: 100%;
}

body {
  background: linear-gradient(to top left, aquamarine, #361356);
  background-attachment: fixed;
}

a:hover {
  text-decoration: none;
}

.main {
  top: 130px;
}

.section {
  margin: 10px 0px;
}

.close {
  position: absolute;
  right: 20px;
  z-index: 99;
  font-size: 46px;
  display: none;
}

#results {
  display: none;
}

.result {
  border: 1px rgba(255,255,255,0.6) solid;
  border-radius: 7px;
  margin: 7px 0px;
  background-color: rgba(255,255,255,0.3);
  transition: background-color 1s;
}

.result:hover {
  background-color: rgba(255,255,255,0.8);
}

.title {
  color: #361356;
  font-variant: small-caps;
  font-size: 32px;
}

.desc {
  color: black;
  font-size: 14px;
}

#credits {
  position: fixed;
  bottom: 5px;
  right: 5px;
  color: #361356;
}

#credits a:hover {
  text-decoration: underline;
}

@media screen and (max-width: 767px) {
  #credits {
    display: none;
  }
}
              
            
!

JS

              
                $(document).ready(function() {
  $('a').attr('target', '_blank');

  var showResults = function() {
    $('.close').show();
    $('#searchButton').slideUp();
    $('.main').animate({
      top: '0px'
    }, function() {
      $('#results').slideDown();
    });
  };

  var hideResults = function() {
    $('#searchButton').slideDown();
    $('.close').hide();
    $('.main').animate({
      top: '130px'
    });
    $('#results').slideUp(function() {
      $('#results').html('');
    });
  };

  $('.close').click(hideResults);

  $('#searchForm').submit(function(e) {
    e.preventDefault();
    var searchTerm = $('input:first').val();
    if (searchTerm) {
      $.ajax({
        url: 'https://en.wikipedia.org/w/api.php',
        type: 'GET',
        dataType: 'jsonp',
        data: {
          action: 'opensearch',
          format: 'json',
          search: searchTerm,
          limit: '10'
        },
        success: function(json) {
          if ($('#results').is(':visible')) {
            $('#results').html('');
            $('#results').slideUp(200);
          }
          $.each(json[1], function(ind, title) {
            var $newResult = $('<a target="_blank" href=' + json[3][ind] + '><div class="result"><div class="title">' +
              title + '</div><div class="desc">' + json[2][ind] + '</div></div></a>');
            $('#results').append($newResult);
          }).done(
            showResults()
          );
        },
        error: function(a, b, c) {
          alert('Search unsuccessful: ' + b + ', ' + c);
        }
      });
    }
  });

});
              
            
!
999px

Console