JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<script src="https://fonts.googleapis.com/css?family=Allerta"></script>
<div class="container-fluid">
<div class="row" id="toppy">
<h4 class="title">Wikipedia Viewer</h4>
<h4 class="port">by l-emi</h4>
</div>
<div id="aligner">
<div class="row">
<div id="centbox">
<div class="row">
<button type="button" class="butoni" id="randy">Random article</button>
<input type="text" name="search" placeholder="Or search!" class="butoni" id="searchy">
</div>
</div>
</div>
<div id="resultati">
<ul id="output">
</ul>
</div>
</div>
</div>
CSS
@import url(https://fonts.googleapis.com/css?family=Allerta);
body {
background-color: #F5F5F5;
font-family: 'Allerta', sans-serif;
}
a {
text-decoration: none !important;
color: inherit;
}
a:hover {
color: inherit;
text-decoration:none;
}
div.hidden {
display: none;
}
#toppy {
background-color: #F5F5F5;
height: 2em;
width: 100%;
z-index: 1;
position: fixed;
}
.title {
position: fixed;
left: 0;
margin: 5px;
color: #584559;
}
.port {
position: fixed;
right: 0;
margin: 5px;
color: #584559 !important;
text-decoration: none !important;
}
.port:hover {
cursor: pointer;
cursor: hand;
}
#centbox {
overflow: auto;
position: absolute;
display: inline-block;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: table;
text-align: center;
}
.butoni {
height: 3em;
width: 12em;
}
#randy {
background-color: #584559;
color: #F5F5F5;
border: none;
padding: 0px 15px 0px 15px;
}
#randy:active {
background-color: #473747;
color: #F5F5F5 !important;
}
#searchy {
text-align: center;
border: solid;
border-color: #584559 !important;
border-width: 0.2em;
padding: 10px;
}
#resultati {
background-color: #e3e1df;
padding: 5px;
margin-top: 3.5em;
width: 50%;
position: absolute;
display: inline-block;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#output {
position:absolute;
background-color: #e3e1df;
width:100%;
margin-left: -5px;
}
#aligner {
clear: both;
}
@media screen and (max-width: 680px) {
#resultati {
width: 75%;
}
}
@media screen and (max-width: 500px) {
#resultati {
width: 90%;
}
}
@media screen and (max-width: 310px) {
#resultati {
margin-top: 4.5em;
}
}
JavaScript
$(document).ready(function () {
$(document).keypress(function(e) {
if(e.which == 13) {
//$("#resultati").removeClass("hidden");
var searchTerm = $('#searchy').val();
var url = "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + searchTerm + "&format=json&callback=?";
$.ajax({
type: "GET",
url: url,
contentType: "application/json; charset=utf-8",
async: false,
dataType: "json",
success: function(data){
//console.log(data[1][0]);
//console.log(data[2][0]);
//console.log(data[3][0]);
for (var i = 0; i < data[1].length; i++) {
$('#output').prepend("<li><a href=" + data[3][i] + ">" + data[1][i] + "</a><p>" + data[2][i] + "</p></li>");
$('#centbox').css("top", "14%");
$('#resultati').css("top", "16%");
}
},
error: function(errorMessage){
alert("Error!");
}
})
};
});
$('.port').click(function() {
window.open("http://codepen.io/l-emi/full/XKgYRr/");
});
$('#randy').click(function() {
window.open("https://en.wikipedia.org/wiki/Special:Random");
});
});