cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="mainWrapper">
  
  <div>
  <h1 class="title text-center">Wiki Viewer</h1>
  </div>
  
  <div>
<!--   <input class="text-center" type="text" name="searchBox" placeholder="Search Wiki" id="searchTerm"> -->
    
    <!-- New Search layout -->
    <section id="search">
        <label for="search-input"><i class="fa fa-search" aria-hidden="true"></i></label>
        <input class="form-control input-lg text-center" placeholder="Search wiki" autocomplete="off" spellcheck="false" autocorrect="off" tabindex="1" id="searchTerm">
       
      </section>
    
<!--     end of search input -->
  <div class="button-container text-center">
  <a href="https://en.wikipedia.org/wiki/Special:Random" target="__blank"><button class="btn btn-transparent random-button"><i class="fa fa-random" aria-hidden="true"></i></button></a>
  
    <button class="search-button btn btn-transparent" type="submit"><i class="fa fa-search" aria-hidden="true"></i></button>
    </div> 
   
  </div>

  
  <div class="result-list">
  </div>
  
</div>

  
  
  
  </div>

            
          
!
            
              body {
  background-color: #391356;
  color: #fff;
}

#mainWrapper {
  max-width: 50%;
  margin: auto;
  position: relative;
  -webkit-transition: all .3s linear 0s;
  transition: all .3s linear 0s;
  
}

 #search {
   position: relative;
  font-size: 18px;
  margin: 30px auto 0;
   background-color:#fff;
   border-radius: 25px;
}

#search label {
    position: absolute;
    left: 17px;
    top: 8px;
    color: #555;
}

.input-lg {
    height: 46px;
    padding: 10px 5px;
  margin-left: 33px;
    font-size: 18px;
    line-height: 1.3333333;
    background-color: transparent;
    border: none;
  border-radius: 25px; 
  width: 90%;
}


.result-item {
  margin-top: 30px;
  padding: 20px 20px 5px;
  background-color: #724C8F;
  color: #fff;
  border-radius: 5px;
}

.result-item:hover {
  background-color: #9476AB;
}

a:hover {
  text-decoration:none;
}

.button-container {
  margin-top: 30px;
}

.btn-transparent {
  background: #724C8F;
  border: none;
  color: #fff;
  padding: 15px 19px;
  margin: 0 10px;
  border-radius: 50%;
}

.btn-transparent:hover {
  border: none;
  background: #9476AB;
  cursor: pointer; 
}
            
          
!
            
              $(document).ready(function() {

  $(updateBoxDimension);
  // $(window).on('resize', updateBoxDimension);
  
  $(".search-button").on("click", results);
  
  $('#searchTerm').keyup(function(e) {

    if (e.keyCode == 13) {
      
      $(results);

    }

  })

});



  

//   $('#searchTerm').bind("enterKey", function(e) {

//     var search = $('#searchTerm').val();

//     var apiUrl = "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=20&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=" + search + "&callback=?";

//     alert(apiUrl);

//     window.open(apiUrl);

//     $.getJSON(apiUrl, function(json) {
      
      
//     });

//   });
  
  
  
  function results() {
    
    $.getJSON("https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=20&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=" + document.getElementById("searchTerm").value + "&callback=?", function(json) {
      
      var html = "";
      
      for (var key in json.query.pages) {
        html += "<a href = 'https://en.wikipedia.org/?curid=" + json.query.pages[key].pageid + "' target='__blank'><div class='result-item'><h4>" + json.query.pages[key].title + "</h4><p>" + json.query.pages[key].extract + "</p></div></a>";
        
        $(".result-list").html(html);
        
        
        
      }
      
    });
    
    $('#mainWrapper').css('top', '20px');
 
  };
  
  

  function updateBoxDimension() {
    var $box = $('#mainWrapper');

    // To center the box
    var boxTop = ($(window).height()) / 2 - ($box.height() / 2);

    $box.css({
      
      top: boxTop
    });
  }
            
          
!
999px
Loading ..................

Console