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

Packages

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.

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

              
                <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">

<body class="container-fluid">
  <section class="search">
         <form class="row text-center">
         <div id="query-box" class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3">
           <h1 class="wiki">Wikipedia Search&nbsp;&nbsp;<i class="fa fa-search faa-wrench animated" aria-hidden="true"></i>
</h1>
            <h1 class="learn">I want to learn about</h1> 
            <div class="input-group">
               <input id="query" placeholder="Search..." type="text" class="form-control" accept="audio/*" autocomplete="on" autofocus aria-label="write here what you want to learn about">
               <span class="input-group-btn">
                 <button id="query-button" class="btn btn-default" type="submit">Go!</button>
               </span>
            </div><!-- /input-group -->
         </div> <!-- col -->
      </form> <!-- row -->
          <div class="row">
         <div class="col-xs-8 col-xs-offset-2 text-center">
            <div id="no-query" class="hidden">
               <h2>Don't resign from a chance to learn something new.<br/>Try <span class="accent-hint">Choose For Me</span> option.</h2>
            </div>
            <button id="random" class="btn btn-default">
               Choose For Me
            </button>
         </div> <!-- col -->
      </div> <!-- row -->
  </section>
  
 
 <section class="random-result row">
   <div class="yellow-box col-xs-12 col-sm-8 col-sm-offset-2 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
       <h2 id="random-result-title"></h2>
       <div id="random-result"></div>
   </div> <!-- col -->
 </section> <!-- row -->
  
 <section class="list-result row">
   <div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
         <ul id="article-list"></ul>
   </div> <!-- col -->
 </section>  <!-- row -->
  
     <footer>
      <div id="back-to-top" class="row text-right hidden">
         <a id="arrow-top" href="#query-box" class="accent">
            back to top
            <span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
         </a>
      </div> <!-- row -->
      <div class="row text-center">
         <div class="col-xs-12 col-sm-4">
            To read the whole article in <a href="https://www.wikipedia.org/" target="_blank" class="accent-link">Wikipedia</a><br/>click/tap the title.
         </div>
         <div class="col-xs-12 col-sm-4">
            Wiki Viewer App<br/>
            Read, learn, practice!
         </div>
         <div class="col-xs-12 col-sm-4">
            Created by Annu<br/>
         </div>
      </div><!-- row -->
   </footer> 
  
</body>

              
            
!

CSS

              
                body{
  font-family: 'Old Standard TT';
  color: #161616;
  background-color: #ede0ce;
}
.wiki{
  font-weight:bold;
  font-size:2em;
  color:#505050;
  padding-top:2em;
}
.learn{
  padding-bottom:1.2em;
}
#query{
  border-color: #161616;
}
#no-query h2 {
   padding-top:1.2em;
   font-size: 0.5em;
}
.list-result ul {
   padding-left: 0;
}
.list-result li h2, #random-result-title {
  font-size: 1.5em;
  background-color: #ede0ce;
  padding: 0;
  border-radius:5px;
}
.list-result li h2 a, #random-result-title a {
   display: block;
   padding: 0.5em;
 }
.list-result li {
   list-style-type: none;
   background-color: #ffba82;
   margin-bottom: 1.5em;
   padding: 1em;
   border-radius: 10px;
}
.list-result li h2 a:hover,
.list-result li h2 a:focus,
.list-result li h2 a:active,
#random-result-title a:hover, 
#random-result-title a:focus,
#random-result-title a:active {
   background-color: #fc4437;
  border-radius:5px;
}

#query-button {
   background-color: #fc4437;
   font-weight:bold;
   font-size:1.1;
   border-color: #161616;
}
#random, .list-result {
   margin-top: 2em;
}
#random {
   background-color: transparent;
   border-color: #161616;
   font-size:1.1em;
}
#random.look {
   background-color: #FFECB3;
   color: #616161;
}
#random:hover,
#random:focus{
 background-color:#fc4437; 
}
#query-button:hover,
#query-button:focus {
   color: #FFF;
}
.random-result {
   display: none;
}
.random-result > * {
   background-color: #FFECB3;
   padding: 0 2em 2em;
}
.random-result, .intro {
   margin-top: 5em;
}
footer {
   color: #161616;
  font-size:1.1em;
}
footer div {
   padding-bottom: 1.2em;
}
.accent {
   color: #fc4437;
}
.accent-link {
   color: #fc4437;
}
.accent-hint {
   color: #fc4437;
}
footer a:hover,
footer a:focus {
   color: #F50057;
}
#arrow-top {
   padding-right: 100em;
}
.list-result p, #random-result p,
.list-result li, #random-result li {
   font-size: 1.2em;
}
.yellow-box {
   overflow: hidden;
   border-radius: 0 10px 10px 0;
}

/* media queries */
@media screen and (min-width: 1200px){
   #no-query h2 {
      font-size: 2em;
   }
   footer {
      margin-top: 100px;
   }
   .search {
      padding-top: 3em;
   }
   #arrow-top {
      padding-right: 5em;
   }
}
@media screen and (max-width:1199px){
   footer {
      margin-top: 5em;
   }
  h1{
    font-size:2.5em;
  }
  .wiki{
    font-size:1.5em;
  }
}
@media screen and (max-width:767px){
   .list-result p, #random-result p,
   .list-result li, #random-result li {
      font-size: 1em;
   }
  h1{
    font-size:2em;
  }
 }

/*/////SEARCH ICON ANIMATION/////*/
@-webkit-keyframes wrench {
  0% {
    -webkit-transform: rotate(-12deg);
    transform: rotate(-12deg);
  }

  8% {
    -webkit-transform: rotate(12deg);
    transform: rotate(12deg);
  }

  10% {
    -webkit-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  18% {
    -webkit-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  20% {
    -webkit-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  28% {
    -webkit-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  30% {
    -webkit-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  38% {
    -webkit-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  40% {
    -webkit-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  48% {
    -webkit-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  50% {
    -webkit-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  58% {
    -webkit-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  60% {
    -webkit-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  68% {
    -webkit-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  75% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
}

@keyframes wrench {
  0% {
    -webkit-transform: rotate(-12deg);
    -ms-transform: rotate(-12deg);
    transform: rotate(-12deg);
  }

  8% {
    -webkit-transform: rotate(12deg);
    -ms-transform: rotate(12deg);
    transform: rotate(12deg);
  }

  10% {
    -webkit-transform: rotate(24deg);
    -ms-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  18% {
    -webkit-transform: rotate(-24deg);
    -ms-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  20% {
    -webkit-transform: rotate(-24deg);
    -ms-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  28% {
    -webkit-transform: rotate(24deg);
    -ms-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  30% {
    -webkit-transform: rotate(24deg);
    -ms-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  38% {
    -webkit-transform: rotate(-24deg);
    -ms-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  40% {
    -webkit-transform: rotate(-24deg);
    -ms-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  48% {
    -webkit-transform: rotate(24deg);
    -ms-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  50% {
    -webkit-transform: rotate(24deg);
    -ms-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  58% {
    -webkit-transform: rotate(-24deg);
    -ms-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  60% {
    -webkit-transform: rotate(-24deg);
    -ms-transform: rotate(-24deg);
    transform: rotate(-24deg);
  }

  68% {
    -webkit-transform: rotate(24deg);
    -ms-transform: rotate(24deg);
    transform: rotate(24deg);
  }

  75% {
    -webkit-transform: rotate(0deg);
    -ms-transform: rotate(0deg);
    transform: rotate(0deg);
  }
}

.faa-wrench.animated,
.faa-wrench.animated-hover:hover,
.faa-parent.animated-hover:hover > .faa-wrench {
  -webkit-animation: wrench 2.5s ease infinite;
  animation: wrench 2.5s ease infinite;
  transform-origin-x: 90%;
  transform-origin-y: 35%;
  transform-origin-z: initial;
}
              
            
!

JS

              
                function randomArticle() {
   $.getJSON("https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&generator=random&grnnamespace=0&callback=?", function(result)  {
      // button Choose For Me ready to be clicked again
      $("#random").attr("disabled", false);
      // hiding intro (empty state) before displaying the response from API
      cleanIntro();
      $.each(result.query.pages, function(key, page){
         $("#random-result-title").html('<a href="http://en.wikipedia.org/?curid=' + page.pageid + '">' + page.title + '</a>');
         $("#random-result").html(page.extract);
         return false; //to display 1st element and finish the loop
      });
      $(".random-result").slideDown(function () {
         arrowBack();
      });
   });
}

function searchArticle(query){
   $.getJSON("https://en.wikipedia.org/w/api.php?action=query&format=json&generator=search&grnnamespace=0&prop=extracts&exlimit=max&explaintext&exintro&gsrsearch=" + query + "&callback=?", function(result) {
      // button Choose For Me ready to be clicked again
      $("#query-button").attr("disabled", false);
      // hiding intro (empty state) before displaying the result from API
      cleanIntro();
      if (result.hasOwnProperty("query")) {
         $.each(result.query.pages, function(key, page){
            var extract = page.extract.length > 200 ? page.extract.substring(0,200) + "..." : page.extract;
            $("#article-list").append('<li><h2><a href="http://en.wikipedia.org/?curid=' + page.pageid + '">' + page.title + '</a></h2>' + '<p>' + extract + '</p>' + '</li>');
         });
      } else {
         hintChange(true);
      }
      arrowBack();
   });
}

function cleanIntro (){
   $(".intro").hide();
}

function hintChange (turnOn) {
   if (turnOn) {
     $("#no-query").removeClass("hidden");
     $("#random").addClass("look");
   } else {
     $("#no-query").addClass("hidden");
     $("#random").removeClass("look");
   }
}

// back-to-top link visibility set
function arrowBack (){
   if (!$(".intro").is(":visible") && $("body").height() - $("footer").height() > $(window).height()){
      $("#back-to-top").removeClass("hidden");
   } else {
      $("#back-to-top").addClass("hidden");
   }
}

$(document).ready(function() {
   $("#random").on("click", function(e) {
      // random button unfocusing
      $(this).blur();
      // disable the button before getting the response from API
      $(this).attr("disabled", true);
      // hiding article-list
      $("#article-list").hide();
      // hiding no-query help text and removing yellow look background of random after random being chosen
      hintChange(false);
      randomArticle();
      e.preventDefault();
   });
   $("#query-button").on("click", function(e) {
      // cleaning after previous search
      $("#article-list").html(""); 
      // making article-list visible again
      $("#article-list").show();
      // cleaning random result if displayed
      $(".random-result").slideUp(function (){
         // when content slided up calling arrowBack() when query is empty back-to-top section
         arrowBack();
      });
      if ($("#query").val() === "") {
         // if input is empty let's display empty state help and clean intro image
         cleanIntro();
         hintChange(true);
         // if random hovered over #no-query span class removed else visible
         $("#random").hover(function() {
               $("#no-query span").removeClass("accent-hint");
            }, function() {
               $("#no-query span").addClass("accent-hint");
            });
      } else {
         // disable the button before getting the response from API
         $(this).attr("disabled", true);
         // passing input text
         searchArticle($("#query").val()); 
         hintChange(false);
      }
      e.preventDefault();
   });
   // back-to-top focus 
   $("#arrow-top").on("click", function() {
      $("#query").focus().select();
   });
});

              
            
!
999px

Console