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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

	<div class="buttons row">
		<div class="col-md-12" align="center">	
			<a href="#" class="button-search" onclick="getSearch();">
				<i class="fa fa-search fa-5x" aria-hidden="true"></i>
			</a>
		</div>
	</div>

	<div class="search-box row">
		<div class="col-md-12" align="center">
			<input type="text" id="search-field" class="form-control" placeholder="Search Wikipedia for an article...">
		</div>
	</div>

	<div class="buttons row">
		<div class="col-md-12" align="center">
			<a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">
				<i class="fa fa-random fa-5x" aria-hidden="true"></i>
			</a>
		</div>
	</div>

</div>
<div class="container" id="results">
	
</div>
              
            
!

CSS

              
                *{
  padding:0px;
  margin:0px;
}

#search-field {
	width: 255px;
	font-size: 17px;
	text-align: center;
}

a,
a:hover,
a:visited{
	color: #0f0f0f;
	text-decoration: none;
}

a:hover {
	font-size: 19px;
}

.buttons,
.search-box {
	margin-top: 50px;
}

.center {
	text-align: center;
	align: center;
}

.bottom {
	vertical-align: bottom;
}

.description {
	height: inherit;
}

body {
	background: #f0f0f0;
}

.img {
	max-height: inherit;
	vertical-align: center
}

h1 {
	color: #0f0f0f;
}

p {
	font-size: 17px;
}
              
            
!

JS

              
                $(document).ready(function(){
	
	//Get input from search box;
	var searchValue;
	window.getSearch = function() {
		
		$("#results").html(""); //Clear any earlyer results if there were any;
		searchValue = document.getElementById("search-field").value;
		ajax(); //Run ajax request
		
	};
	
	//Wikipedia API request url;
	var API = 'https://en.wikipedia.org/w/api.php?'+
		 'action=query'+
		 '&format=json'+
		 '&origin=*'+
		 '&prop=extracts|pageimages|info'+
		 '&generator=search'+
		 '&utf8=1'+
		 '&exchars=175'+
		 '&exlimit=10'+
		 '&exintro=1'+
		 '&explaintext=1'+
		 '&exsectionformat=plain'+
		 '&piprop=thumbnail'+
		 '&pithumbsize=190'+
		 '&pilimit=10'+
		 '&inprop=url'+
		 '&gsrlimit=10'+
		 '&gsrsearch=';
		 

	//Function for getting data from wikipedia; 
	function ajax(){
		$.ajax( {
			url: API + searchValue,
			dataType: 'json',
			success: results,
			error: function (){
				console.log('Error');
			}
		});
	}
	
	//Function for displaying data;
	function results(data){
		
		//Check if there are results
		if(typeof data.query == "undefined") {
			$("#results").append('<h1 class="not-found animated slideInUp" align="center">Sorry, no results found for: '+ searchValue +'</h1>');
		} else {
			$("#results").append('<h1 class="animated slideInUp" align="center">Search results for: <b>'+ searchValue +'</b></h1>')
		};
		
		//Get values of pages object to use in for loop
		var getPages = Object.getOwnPropertyNames(data.query.pages); 
		for ( i=0; i < getPages.length; i++ ){
			
			var page = data.query.pages[getPages[i]];
			$("#results").append(
				'<div class="row well well-sm search-result animated slideInUp">'+
				'<div class="col-md-2 col-sm-12 col-xs-12 center">' +
					(typeof page.thumbnail != "undefined" ?  //Check if post has a thumbnail
					'<img src=' + page.thumbnail.source + ' class="img vertical-center">': '<img src="https://upload.wikimedia.org/wikipedia/commons/8/8b/Wikipedia-logo-blank.svg" class="img vertical-center">') +
				'</div>'+
				'<div class="col-md-10 col-sm-12 col-xs-12 description">'+
					'<h1 class="center">' + page.title + '</h1>' +
					'<p>' + page.extract + '</p>' +
					'<p class="center"><a href="' + page.fullurl + '" target="_blank" >Read more on Wikipedia <i class="fa fa-external-link" aria-hidden="true"></i></a></p>' +
				'</div>'+
				'</div>'
			);			
		}; //End of for loop;
	}; //End of results(data);
}); //End of document.ready;


              
            
!
999px

Console