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

              
                <!-- Imported resources -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
<!-- Code starts here -->
<div class="container-fluid">
  <!-- Only change code below this line-->
  <div class="title-box centered"><h1>Welcome to Wikipedia Search Engine</h1>
  </div>
  <div class="interactive">
    <div id="random-page">
        <a id="random-btn"  href="https://en.wikipedia.org/wiki/Special:Random"><i class="fa fa-random"></i> Random</a>
    </div>
    <div id="search-box">
        <i class="fa fa-search">
          <input id="text-search" type="text" placeholder="Please Type Here"></i>
        <button type="submit" id="submit-btn" class="btn btn-default colswitch">Search</button>
          </div>
  </div>
  <div class="output centered"></div>
  
  <div id="bottom-bar" class="centered">&copy;MarkoDev 2018 <br>Wikipedia Search Page</div>
  <!-- Only change code above this line-->
</div>
              
            
!

CSS

              
                .centered {
  text-align: center;
  position: fixed;
  top: 50%;
  right: 50%;
  transform: translate(50%, -50%);
}
.title-box {
  position: fixed;
  top: 4%;
   background-color: rgba(255,255,255,0.7);
   padding: 5px;
  width: 80%;
  color: black;
}
html{
  background: url(https://www.popsci.com/sites/popsci.com/files/images/2017/02/wikipedia_mini_globe_handheld.jpg) no-repeat center center fixed;
  background-size: cover;
}

#random-btn {
  float: left;
  position: fixed;
  top: 10%;
  left: 25%;
  text-align: center;
  font-size: 1.5em;
  text-decoration: none;
  padding: 10px;
  background-color: rgba(255,255,255,0.8);
  color: #fc0505;
  border: 5px solid rgba(0, 0, 0, 1);
}
#search-box {
  float: right;
 position: fixed;
  top: 10%;
  right: 15%;
 font-size: 1.5em;
 color: #fc0505;
 background-color: rgba(255,255,255,0.8);
  padding: 10px;
  border: 5px solid rgba(0, 0, 0, 1);
}
#text-search {
  padding: 5px;
  border: none;
  color: #fc0505;
}
#submit-btn {
  font-size: 0.8em;
  background-color: #fc0505;
  color: rgba(0, 0, 0, 1);
  border: 3px solid rgba(0, 0, 0, 1);
}
.output {
  top: 60%;
  width: 90%;
  height: 60%;
  color: black;
  text-align: left;
  overflow-y: auto;
}
.output h4 {
  color: black;
  font-size: 1em;
  font-weight: bold;
  
}
.output span {
  font-size: 0.8em;
}
.entryBox {
  background-color: rgba(255,255,255,0.7);
  padding: 10px;
  margin: 10px;
}
#bottom-bar {
  width: 100%;
  top: 97%;
  background-color: rgba(255,255,255,0.5);
  text-align: center;
}
              
            
!

JS

              
                $("document").ready(function(){
  //Button colour switches
  $(".colswitch").hover(function() {
    $(this).css("background-color", "rgba(0,0,0,1)");
    $(this).css("color", "rgba(255,255,255,1)");
    $(this).css("border", "3px solid rgba(255,255,255,1)");
  }, function() {
    $(this).css("background-color", "rgba(255,255,255,0.8)");
    $(this).css("color", "rgba(0, 0, 0, 1)");
    $(this).css("border", "3px solid rgba(0, 0, 0, 1)");
  });
   //Submit button action
$("#submit-btn").on("click", function() {
var input = $("#text-search").val();
var searchURL = "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&prop=extracts&exsentences=1&search="+input+"&limit=8&callback=?";


//Ajax attempt
$.ajax({
type: "GET",
url: searchURL,
dataType: "json",
success: showData,
error: function(errorMsg) {
console.log("Error");
}
});

function showData (data) {
  for (i = 0; i < 8; i++) {
    var entries = "<div class=\"entryBox\"><a href="+data[3][i]+"><h4>"+data[1][i]+"</h4></a><span>"+data[2][i]+"</span></div>";
    $(".output").append(entries);
  };
};
/*
//getJson attempt
$.getJSON(searchURL, function (data) {
console.log(data);
});
*/
});
  
  
  //No changes below this line
});
              
            
!
999px

Console