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

              
                
<html lang="en">

<head>
    <title>Wikipedia viewer</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="style.css" rel="stylesheet">
    <link rel="stylesheet" href="font-awesome.css">
</head>

<body>
    <section class="container-fluid">
        <i id="image" class="fa fa-wikipedia-w"></i>
        <h1 id="main-title">Wikipedia</h1>
        <h2 id="sub-title">Search Articles</h2>
        <form id="search-form" class="container-fluid">
            <input id="search-keyword" type="text" placeholder="Search.." class="form-control">
            <button id="submit-btn" type="submit">
            <i class="fa fa-search"></i>
        </button>
        </form>
        <a href="https://en.wikipedia.org/wiki/Special:Random" target="_black">
            <button id="random" type="submit">Random Article</button>
        </a>
    </section>
    <div id="container" class="container-fluid">
        <div id="container-row" class="row">

        </div>
        <p id="credit">A Pen By Shola</p>
    </div>
</body>
<script src="script.js"></script>

</html>
              
            
!

CSS

              
                body {
    background-color: rgb(35, 241, 241);
    color: #333;
}

section {
    text-align: center;
    padding: 20px;
    color: rgb(255, 255, 255);
}

#image {
    border-bottom: solid 3px rgb(34, 230, 214);
    padding-bottom: 5px;
    color: rgb(42, 44, 177);
}

#main-title {
    letter-spacing: -2px;
    font-size: 3em;
    font-weight: 700;
    margin: 5px;
}

#sub-title {
    letter-spacing: 3px;
    margin-top: 5px;
    color: rgb(42, 44, 177);
}

form {
    margin: 20px auto 20px auto;
    padding: 20px;
    border-bottom: solid 2px rgb(238, 238, 238);
    border-top: solid 2px rgb(238, 238, 238);
    border-radius: 100px;
    max-width: 500px;
}

#search-keyword {
    margin-left: auto;
    margin-right: auto;
    padding: 5px 10px 5px 10px;
    border-radius: 20px;
    border: solid 2px rgb(238, 238, 238);
    max-width: 250px;
    display: inline-block;
}

#submit-btn {
    padding: 5px 10px 5px 10px;
    margin-top: 5px;
    border: 0;
    background-color: transparent;
    cursor: pointer;
    color: rgb(42, 44, 177);
    font-size: 30px;
}

#submit-btn:hover {
    color: rgb(94, 91, 91);
    padding: 5px 10px 5px 10px;
}

#random {
    padding: 10px 12px 10px 12px;
    background-color: rgb(77, 163, 19);
    border: 0;
    border-radius: 5px;
    cursor: pointer;
    color: rgb(255, 255, 255);
    font-size: 0.9em;
}

button,
input,
{
    outline: none;
}

button:focus,
input:focus {
    outline: none;
}

#container {
    margin: 0;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    max-width: 960px;
}

#error {
    margin-left: auto;
    margin-right: auto;
    color: white;
}

.article {
    padding: 0;
    margin: 0;
    margin-top: 15px;
    text-align: center;
    line-height: 25px;
}

.article-header {
    letter-spacing: 1.2px;
    margin-bottom: 0;
    padding: 10px;
    background-color: rgb(255, 255, 255);
    border-left: solid 5px rgb(42, 44, 177);
    border-right: solid 5px rgb(34, 230, 204);
    border-top-left-radius: 5px;
    color: rgb(116, 116, 116);
}

.article-header a {
    font-size: 0.9em;
}

.article-body {
    font-size: 0.9em;
    text-align: left;
    letter-spacing: 1px;
    padding: 5px;
    padding-left: 10px;
    margin-top: 0;
    background-color: rgb(255, 255, 255);
   



#credit {
    color: rgb(42, 44, 177);
    text-align: center;
    font-size: 20px;
    margin-top: 30px;
}
              
            
!

JS

              
                $(document).ready(function() {
    var formArea = $('#search-form');
    var formField = $('#search-keyword');
    var containerRow = $('#container-row');
    var searchInput;

    formArea.on('submit', function(event) {
        event.preventDefault();
        containerRow.html('');
        searchInput = formField.val();

        $.ajax({
            url: 'https://en.wikipedia.org//w/api.php?action=query&list=search&srsearch=' + searchInput + '&format=json&origin=*',
            success: addArticles
        });
    });

    function addArticles(results) {
        var myContent = '';

        if (results && results.query.search && results.query.search.length >= 1) {
            myContent = results.query.search.map(function(item) {
                return '<div class="article col-md-4"><div class="article-header"><h3 class="article-title"><a href="https://en.wikipedia.org/?curid=' +
                    item.pageid + '" target="_blank"> ' + item.title + '</a></h3></div><div class="article-body p-2 m-2"><p>' +
                    item.snippet + '</p></div></div>'
            }).join('');
        } else {
            mylContent = '<div id="error">No match found</div>';
        }

        containerRow.html(myContent).hide();
        containerRow.html(myContent).slideDown(800);

    };

});
$(document).ready(function() {
    var formArea = $('#search-form');
    var formField = $('#search-keyword');
    var containerRow = $('#container-row');
    var searchInput;

    formArea.on('submit', function(event) {
        event.preventDefault();
        containerRow.html('');
        searchInput = formField.val();

        $.ajax({
            url: 'https://en.wikipedia.org//w/api.php?action=query&list=search&srsearch=' + searchInput + '&format=json&origin=*',
            success: addArticles
        });
    });

    function addArticles(results) {
        var myContent = '';

        if (results && results.query.search && results.query.search.length >= 1) {
            myContent = results.query.search.map(function(item) {
                return '<div class="article col-md-4"><div class="article-header"><h3 class="article-title"><a href="https://en.wikipedia.org/?curid=' +
                    item.pageid + '" target="_blank"> ' + item.title + '</a></h3></div><div class="article-body p-2 m-2"><p>' +
                    item.snippet + '</p></div></div>'
            }).join('');
        } else {
            mylContent = '<div id="error">No match found</div>';
        }

        containerRow.html(myContent).hide();
        containerRow.html(myContent).slideDown(800);

    };

});
              
            
!
999px

Console