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.

            
              
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
<div class="background"></div>
<div class="flexContainer_row">
<form name="searchForm" onsubmit="searchWikipedia" class="flexForm form" id="form">
  
  <input class="textInput" type="text" name="wikiSearch"></input>
<div id="searchButton" class="searchButton" type="submit">  

<i class="material-icons searchIcon">search</i>
</div>

  
<div class="textButton" >  
<a id = "randomSearch" href="https://en.wikipedia.org/wiki/Special:Random"> random</a></div>
  
</form>
</div>

<div id="results" class="flexContainer_column results"></div>

            
          
!
            
              .flexContainer_column {
  display: flex;
  justify-content: center;
  flex-direction: column;
}
.flexContainer_row {
  display: flex;
  justify-content: center;
  height: 200px;
}
.flexElement {
  
  margin: auto;
}

.results>a {
  text-decoration: none;
  width: 800px;
  margin: auto;
}

.results>a>div {
  
  padding: 20px;
  margin-top: 20px;
  background-color: #f5f5f5;
  color: rgba(0,0,0,.87);
  text-decoration: none;
  box-shadow: 3px 4px 8px rgba(0,0,0,.2);
  border-radius: 2px;
}

.flexForm {
  margin: auto;
  
}
.form {
  
}
.background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: -1;
  height: 300px;
  background-color: #f4511e;
  box-shadow: 0px 2px 5px rgba(0,0,0,0.3);
}
body {
  background-color: #E1E2E1;
  font-family: 'Roboto', sans-serif;
  color: rgba(0,0,0,.87);
}
.textInput {
  background-color: transparent;
  border-width: 0px 0px 3px 0px;
  border-color: rgba(0,0,0,.87);
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  font-size: 36px;
  color: rgba(0,0,0,.87);
  float: left;
}
.textInput:focus {
  outline: none;
}

input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px #f4511e inset;
}

.searchButton {
  position: relative;
  cursor: pointer;
  float: left;
  margin-left: 20px;
}
.searchButton:hover {
  color: white;
  
}
.searchIcon {
 
 font-size: 48px !important;
}

.textButton {
  
  color: inherit;
  font-weight: 500;
  border: 2px black solid;
  border-radius: 5px;
  padding: 10px;
  float: left;
  margin-left: 20px;
  
}
.textButton>a{
  color: inherit;
  text-decoration: none;
}
.textButton:hover {
  border-color: white;
  color: white;
}
            
          
!
            
              
  

  
let searchForm = document.forms.searchForm;
let randomSearch = document.getElementById("randomSearch");
let searchField = searchForm.elements.wikiSearch;
let submitSearch = document.getElementById("searchButton");
searchField.value = "sharks";
let baseURL = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts%7Cpageimages&titles=Title&generator=search&redirects=1&exsentences=2&exlimit=10&exintro=1&piprop=thumbnail%7Cname&pilimit=50&gsrsearch="

//submitSearch.onclick 
submitSearch.onclick = function () {
  searchTerm = searchField.value;
  searchURL = baseURL+searchTerm;
  $.ajax({
    url: searchURL,
    type: 'GET',
    dataType: 'jsonp',
    success: function (data) {
      displayResults(data); 
    }
});    
}

function displayResults(data){
  //clear old search results
  document.getElementById("results").innerHTML="";
  pages = data["query"]["pages"];
  for (pageNumber in pages){
        var result = new Result(pageNumber);
        result.addEntry();
      }
}

function Result( x){
  this.title = pages[x]["title"];
  this.extract = pages[x]["extract"];
  this.link = "https://en.wikipedia.org/?curid="+[x];
  
  this.addEntry = function() {
    document.getElementById("results").innerHTML+="<a href="+this.link+"><div class="+"flexElement"+"><h2>"+this.title+"</h2>"+"<p>"+this.extract+"</p></div></a>";
  }
}
            
          
!
999px
Loading ..................

Console