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-fluid d-flex justify-content-center" id="container">
  
  <div class="row align-self-center">
       
  <!---------WRAPPER----------->
  <div id="wrapper">
    
    <!---------ERROR---------->
    <span class="alert-danger" id="alert">
      <p><strong>Ouch! </strong>Searched value not found.</p>
    </span>
    
    <!--SEARCH BAR-->
   <div id="search-wrap">
      <i class="fa fa-search" aria-hidden="true"></i> <!--search icon-->
      <a id="search-clear"><i class="fa fa-times-circle" aria-hidden="true"></i></a> <!--close icon-->
    <form>
      <input type="search" class="form-control" autocomplete="off" placeholder="Search Wikipedia..." aria-label="Search Wikipedia..." id="search-bar">
    </form>
   </div>
    
    <!--RANDOM ARTICLE-->
      <a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank" id="random-art">Click here for a random article!</a>
  
   </div><!--wrapper-->
   </div><!--row-->
  
  <!------FOOTER_1-------->
  <div id="footer_1">
    <p class="text-center" id="footer">Designed and coded by <a href="https://codepen.io/dknvmlhok/full/QqEjMw" class="text-dark" id="footer-name" target="_blank"><strong>Dominik Kohlman</strong></a></p>
  </div> 
  
  </div><!--container-->

<!------RESULTS------->
    <div id="card-list"><!--new cards go here!--></div>
<!------FOOTER_2-------->
    <div id="footer_2"><!--here goes below-results-footer--></div>


              
            
!

CSS

              
                html,body {
  height: 100%;
}
body {
  background-image:url('https://s20.postimg.cc/pdp2rhd4t/mosaic-bg.jpg');
  background-size:cover;
  background-attachment:fixed;
}
#container {
  height: 100%;
}
#search-bar{
  width: 198px;
  height: 39px;
  padding-left: 30px;
  padding-right: 30px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  border:1px solid black;
  background-color: rgba(255, 255, 255, 0.4);
  color: black;
}
.form-control:focus{
  border-color: #7952b3 !important;
  -webkit-box-shadow: 0 0 0 3px rgba(121,82,179,.25) !important;
  -moz-box-shadow: 0 0 0 3px rgba(121,82,179,.25) !important;
  box-shadow: 0 0 0 3px rgba(121,82,179,.25) !important; 
}
form{
  display:inline-block;
}
#search-wrap{
  position:relative;
}
.fa-search {
  position:absolute;
  padding: 12px 9px;
  color: #191919;
}
#search-clear{
  position:absolute;
  display:none;
  padding: 0px;
  margin-top: 8px;
  margin-left: 228px;
  color: #21252957;
  cursor: pointer;
}
#search-clear:hover{
  color: #2125298a;
}
#random-art{
  font-family: 'Quicksand', sans-serif;
  font-size: 18px;
  color:inherit;
  text-decoration:none;
  display:inherit;
  margin-top:15px;
}
#alert{
  display:none;
}
#wrapper{
  width: 100%;
  margin: 0 auto;
  text-align:center;
}
#card{
  width: 70%;
  margin: 0 auto;
  margin-bottom: 2px;
  border: none;
}
#card:hover{
  -webkit-box-shadow: 0px 0px 10px 4px #868e96;
  -moz-box-shadow: 0px 0px 10px 4px #868e96;
  box-shadow: 0px 0px 10px 4px #868e96;
  z-index:1;
}
#card-list{
  margin-top: 100%;
}
#card-link{
  text-decoration: none;
  color: inherit;
}
#footer_1{
  position:absolute;
  bottom: 0px;
}
#footer_2{
  position: relative;
  margin-top: 20px;
}
#footer-name{
  text-decoration:none;
  color: inherit;
}
              
            
!

JS

              
                $(document).ready(function(){
  
  /***************SEARCH-BAR-ANIMATIONS******************/
  $("#search-bar").on("click",function(){
    $(this).animate({"width":"250px"},400,function(){
    $("#search-clear").fadeIn(200);
    });
  });
  
  $("#search-clear").on("click",function(){ /*close search-bar on click*/
    $(this).fadeOut(90);
    $("#container").height("100%");
    $("#card-list").empty();
    $("#search-bar").val("");
    $("#alert").hide();
    $("#footer").appendTo("#footer_1"); /*place footer to default position*/
    $("#search-bar").animate({"width":"198px"},400);
  });
  
  /******************FORM-SUBMIT****************/
  $("form").submit(function(submit){
   $("#alert").hide();
   $("#card-list").removeAttr('style'); /*repeat card-list animation with every submit*/
   $("#card-list").animate({"margin-top": "0%"},900);
       
 let searchVal = $("#search-bar").val();
 let apiUrl = "https://en.wikipedia.org/w/api.php?action=query&format=json&origin=*&prop=revisions&list=search&formatversion=latest&rvprop=content&srsearch="+searchVal+"&srlimit=10&callback=?";
    
   
 $("#card-list").empty(); /*empty card-list before every submit*/
    
 $.getJSON(apiUrl,function(data){
   
   if(data.query.search != ""){
     $("#container").height("26%");
     /*place footer below results*/ 
     $("#footer").appendTo("#footer_2");
   /*if search value exists iterate through data with for loop and access title and text from data*/
   for(let i=0; i<10; i++){
    let titles = data.query.search[i].title;
    let texts = data.query.search[i].snippet;
    let webUrl = "https://en.wikipedia.org/wiki/?curid="+data.query.search[i].pageid;
     /*create card for every result*/
     $('<div class="card" id="card">'
       +'<a href='+webUrl+' target="_blank" id="card-link">'
       +'<div class="card-body" id="card-body">'
       +'<h4 class="card-title" id="card-title">'+titles+''+'</h4>'
       +'<p class="card-text" id="card-text">'+texts+''+"..."+''+'</p>'  
       +'</div>'+'</a>'+'</div>').appendTo("#card-list")
   }
  }
    else {
        $("#card-list").empty();
        $("#footer").appendTo("#footer_1");
        $("#container").height("100%");
        $("#alert").show();
    }
 });
     if(searchVal === ""){ /*if no value entered*/
        $("#card-list").empty();
        $("#footer").appendTo("#footer_1");
        $("#container").height("100%");
        $("#alert").show();
    }
    submit.preventDefault(); /*prevent page reload after form submit*/
    
  });
}); 

              
            
!
999px

Console