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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <html>
<header>
 <meta name="viewport" content="width=device-width">
 <link rel="stylesheet" type="text/css" href="stylesheet.css">
 <link href="https://fonts.googleapis.com/css?family=Homemade+Apple|Mr+Dafoe|Nothing+You+Could+Do|Reenie+Beanie|Rock+Salt|Walter+Turncoat" rel="stylesheet"> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</header>


<body>
<div id="explanation"> <h2> Note: </h2> <p id="textexplanation"> Wikipedia is a river of information that is gathered by a diversity of human beings. The styling is designed to emphasize this diversity.</p></div>
<div class="searcharea">
<h1> Search Wikipedia! </h1>
  <div class="wrapper">
  <input class="searchfield" id="searchbox" type="text" placeholder="Type something here..."></input>
  <button class="searchbutton"> <p id="search"> Search </p> </button>
  <button class="randomsearch"><a href="https://en.wikipedia.org/wiki/Special:Random"> <p id="random"> Random </p> </a> </button>
  </div>
</div>

<ul id ="results">
</ul>

</body>

<script src="wikipediaviewer.js"></script>

</html>
            
          
!
            
              body {
	background-color: black;
	padding-left: 1em;
	padding-right: 1em;
	padding-top: 2em;
    font-size: 100%;
}

ul {
	padding-left: 0;
}

a {
	text-decoration: none;
}

li {
	padding: 10px;
}

button {
	border-radius: 5px;
	background: none;
	padding: 6px;
	border: 1px;
}

.randomsearch {
  background-color: gold;
  font-size: 22px;
}

#random {
  margin: 5px;
}

//Removes the complete html styling from the buttons.
input, button, submit { border:none; } 

.wrapper {
  white-space: nowrap;
}

.searchfield {
	padding: 10px;
	border: 10px;
	border-style: solid;
	background-color: Ivory;
	border-color: LightPink;
	border-radius: 5px;
	-ms-transform: skewX(20deg); /* IE 9 */
    -webkit-transform: skewX(20deg); /* Safari */
    transform: skewX(20deg); /* Standard syntax */
}

.searcharea {
	margin-left: auto;
	margin-right: auto;
}

.buttonsdiv {
	display: inline-block;
}

.searchbutton {
	background-color: silver;
}

h1 {
	font-family: 'Nothing You Could Do', cursive;
  color: white;
  font-size: 1.667em;
}

h2 {
  color: darkred;
  margin: 0 10px 0 -10px;
  text-align: center;
font-family: 'Mr Dafoe', cursive;
font-size: 1.25em;
}

h3 {
	color: white;
	font-family: 'Rock Salt', cursive;
}

p {
	color: white;
	font-family: 'Homemade Apple', cursive;
	font-size: 0.67em;
}
p#search {
  font-family: 'Walter Turncoat', cursive;
  
  color: white;
}
p#random {
	font-family: 'Reenie Beanie', cursive;
  color: white;
}

#explanation {
  background-color: Beige;
  padding: 10px;
  padding-top: 0;
  margin-top: 20px;
  -ms-transform: rotate(-10deg); /* IE 9 */
    -webkit-transform: rotate(-10deg); /* Safari */
    transform: rotate(-10deg); /* Standard syntax */
}

#textexplanation {
  color: darkblue;
  line-height: 1.5em;
  text-decoration: underline;
} 

@media screen and (min-width: 700px) {
  
  h1 {
	   font-size: 2.5em;
  }
  
  h2 {
	  font-size: 1.875em;
  }
  
  h3 {
	  
  }
  
  p {
	  font-size: 1em;
  }
  
  body {
	padding-left: 20%;
	padding-right: 20%;
	padding-top: 30px;
  }
  .searcharea {
	 padding-left: 20%;
	padding-right: 20%;
  }
   #explanation {
	       margin-right: -135px;
   }
}
@media screen and (min-width: 500px) {
 #explanation {
	  float: right;
	  width: 30%;
  }
}
            
          
!
            
              //https://www.mediawiki.org/wiki/API:Search
  var keyword;
 var randRGB;
var i;

$(document).ready(function(){

       $("#search").click(function(){
         $("ul").empty();
        keyword = $("#searchbox").val();
         $.getJSON( "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + keyword + "&callback=?", function( data ) {
  console.log(data);
           if (typeof data[3][1] !== "undefined") {
             for (i = 0; i<10; i++) {
             randomBGRGB();
             randomFontRGB();
             $("#results").append("<li style=" + backgroundRGB + "> <a href="+data[3][i]+"><h3 style=" + fontRGB + ">"+data[1][i]+"</h3></a><p style=" + fontRGB + ">"+data[2][i]+"</p><li>"); 
           }   
         
           }
             else {
               $("#results").append("<li><h3> No search results.. Search again!</h3></li>");
             }      
		});  
	});
});

 function randomBGRGB() {
              var randNum30 = Math.floor((Math.random() * 30) + 1);
              var randNum3 = Math.floor((Math.random() * 3) + 1); // gives a random number from 1 till 3.
              
               if (randNum3 == 1) {
                 backGroundRGB = "background-color:rgb(" + (225 + randNum30) + ",250,250)";
               }
               else if (randNum3 == 2) {
                 backgroundRGB = "background-color:rgb(250," + (225 + randNum30) + ",250)";
               }
               else if (randNum3 == 3) {
                 backgroundRGB = "background-color:rgb(250,250," + (225 + randNum30) + ")";
               
               }
 }

function randomFontRGB() {
              var randNum30 = Math.floor((Math.random() * 100) + 1);
              var randNum3 = Math.floor((Math.random() * 3) + 1); // gives a random number from 1 till 3.
              
               if (randNum3 == 1) {
                 fontRGB = "color:rgb(" + (randNum30) + ",000,000)";
               }
               else if (randNum3 == 2) {
                 fontRGB = "color:rgb(000," + (randNum30) + ",000)";
               }
               else if (randNum3 == 3) {
                 fontRGB = "color:rgb(000,000," + (randNum30) + ")";
               
               }
 }

//@todo random fonts and background color per result.
//@todo responsive maken
//@todo random button


            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console