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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <img id="wikilogo" src="https://raw.githubusercontent.com/mattpavo/images/master/2000px-Wikipedia-logo-v2-bw.svg.png" alt="Wikipedia's logo" />

<!--Search-->
<section id="searcharea" class="container-fluid">
  <p>Search for an article:</p>
  <div class="form-group">
    <input id="wikisearch" class="form-control" type="text" placeholder="'Enter' to search" />
    <input id="subbutton" type="submit" />
  </div>
</section>

<!--Search results-->
<section class="container-fluid">
  <ul id="searchresults">
  </ul>
</section>

<!--Random-->
<section class="container">
  <a id="rando" class="btn btn-secondary" href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">Random article</a>
</section>

<!-- <footer>
  <div>Coded by Matthew&nbsp;Pavouris</div>
</footer> -->
            
          
!

CSS

            
              body {
  margin-top:80px;
  margin-bottom:50px;
  background-color:#f6f6f6;
  font-size: 15px;
}

#wikilogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 30px;
  width: 110px;
}

section {
  text-align: center;
}

section p {
  margin-bottom: 17px;
}


/* Search input */
#searcharea {
  text-align: center;
  width: 400px;
  text-align: center;
  margin-top: 20px;
  margin-bottom: -8px;
}

@media only screen and (max-width: 450px) {
    #searcharea {
      max-width: 98%;
    }
}

input::-webkit-input-placeholder {
opacity:0.6 !important;
}
 
input:-moz-placeholder { /* Firefox 18- */
opacity:0.6 !important; 
}
 
input::-moz-placeholder {  /* Firefox 19+ */
opacity:0.6 !important;
}
 
input:-ms-input-placeholder {  
opacity:0.6 !important; 
}

#subbutton {
  display: none;
}
/* end */


/* Random article */
.container {
  max-width: 88%;
  margin-bottom: 30px;
}

.btn-secondary {
  background-color: white;
  border: 1px solid #e0e0e0;
  border-radius: 10vw;
}

.btn-secondary:hover {
  background-color: #e8f3ff;
}
/* end */


/* Search results */
ul {
  margin-top: 20px;
  margin-left: auto;
  margin-right: auto;
  width: 800px;
  max-width: 100%;
  text-align:left;
  padding-left: 0px;
}

li {
  background-color: white;
  border: 1px solid #d6d6d6;
  border-radius: 3px;
  margin: 5px;
  padding: 13px;
  list-style-type: none;
}

li p {
  margin-bottom: 0px;
  color: #333;
}

#wikiheading {
  font-weight: bold;
}

li:hover {
  background-color: #e8f3ff;
}
/* End */


a:hover {
  text-decoration: none;
}

a:focus {
  text-decoration: none;
}

/* footer {
  position: absolute;
  bottom: 15px;  
  left: 15px;
  right: 15px;
}

footer div {
  text-align: center;
} */
            
          
!

JS

            
              // window.onload = function() {
//   document.getElementById("wikisearch").focus();
// };

$(document).ready(function() {
  
  $("#subbutton").click(function() {
    
    var searchVal = $("#wikisearch").val();
    var apiURL = "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + searchVal + "&callback=?";
    
    $("#searchresults").empty();
    
    $.get({
      url: apiURL,
      async: false,
      dataType:'json',
      success: resultsFunc
      // error: errorFunc
    })
    
    //Hide 'Random article' button when ul is shown
    $("#rando, footer").show();        
    if (searchVal) {
      $("#rando, footer").hide();
    }
    
    // if (searchVal.split('').length > 0) {
    //   $("rando").hide();
    // }
    // else if (searchVal.split('').length < 1) {
    //   $("rando").show();
    // }

  });//end click func
  
  //Success
  function resultsFunc(data) {
    // //heading
    // console.log(data[1][0]);
    // //description
    // console.log(data[2][0]);
    // //url
    // console.log(data[3][0]);
    
    for (var i = 0; i < data[1].length; i++) {
      $("#searchresults").append("<a href= " + data[3][i] + " target='_blank'><li><p id='wikiheading'>" + data[1][i] + "</p><p>" + data[2][i] + "</p></li></a>");
    }
    
  }//end Success
    
  // "<p>" + data[1][i] + "</p>"
  
  //Success
  // function resultsFunc(apiResult){
  //    $("#rando").hide();
  //    for (var i = 0; i < apiResult.query.search.length; i++){
  //         $("#searchresults").append('<p>' + apiResult.query.search[i].title + '</p>');
  //    }
  // }
  
  // //Error
  // function errorFunc(errorMsg) {
  //   alert("Something went wrong");
  // }
  
  // Search with Enter key
  $("#wikisearch").keyup(function(event) {
    if (event.keyCode == 13) {
      $("#subbutton").click();
      document.activeElement.blur();
    }
  });

}); //end doc ready
            
          
!
999px

Console