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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <html>
<head>
    <meta charset="UTF-8">
    <title>Wikipedia Viewer</title>
</head>

<body class="gradient">
    <main>
        <article class="search-grid">
            <h1> Wikipedia Viewer </h1>
            <div class="form"> 
                <div>
                    <input id="search" type="text" name="wikiText" placeholder="Search"> 
                    <i class="fa fa-search" onclick="Search()"> </i>
                </div>
            </div>
            <a class="random-btn" href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">Random Article</a>
        </article>

        <section id="results"></section>

    </main>
    <footer>Developed &amp; Designed by <a href="https://koop4.github.io/"  target="_blank">Rob.dll</a> & <a href="https://zhannacraftsman.tumblr.com/"  target="_blank">Zhanna</a></footer>
</body>
</html>
              
            
!

CSS

              
                html, body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    margin: 0px;
    padding: 0px;
}

a:hover, a:visited, a:link, a:active {
    text-decoration: none;
}

.gradient {
    background: black; /* For browsers that do not support gradients */
    background: -webkit-linear-gradient(black, #3eb5f1); /* For Safari 5.1 to 6.0 */
    background: -o-linear-gradient(black, #3eb5f1); /* For Opera 11.1 to 12.0 */
    background: -moz-linear-gradient(black, #3eb5f1); /* For Firefox 3.6 to 15 */
    background: linear-gradient(black, #3eb5f1 50%); /* Standard syntax (must be last) */
}


main {
    height: 100%;
    widows: 100%;
    display: flex;
    flex: 1;
    flex-direction: column;
    align-content: center;
    justify-content: center;
}

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

h1 {
    text-align: center;
    color: white;
    margin:0px;
}

.form {
    display: flex;
    justify-content: center;
    margin: 8px auto 15px auto;
}

.form div {
    border: 2px solid white;
    border-radius: 5px;
}

.random-btn {
    background: #e2907a;
    color: white;
    border-radius: 5px;
    margin-top: 20px;
    min-width: 160px;
    text-align: center;
    padding: 2px 25px;
}


.random-btn:hover {
    cursor: pointer;
}

.fa-search {
    color: white;
    background: none;
    border-left: 2px solid white;
    border-radius: 5px;
    padding: 5px;
    cursor: pointer;
}

input {
    color: white !important;
    background: none;
    border: none;
    padding: 5px 10px;
    min-width: 200px;
}


input:focus {
    outline-width: 0;
}

input::-moz-placeholder {  
    color: white !important;
}

input::-webkit-input-placeholder{
    color:white !important;  
}
input::-moz-placeholder {  
    color: white !important;  
}

input:-ms-input-placeholder {  
    color: white !important;
}

section {
    align-self: center;   
    width: 80%;
    margin-top: 30px;
}

.result {
    display: inline-block;
    width: 100%;
    margin-top: 15px;    
    color: white;
    background-color:rgba(0, 0, 0, 0.4);
    padding: 15px 25px;
    border-radius: 5px;
}

.result:hover {
    cursor: pointer;
    transform: scale(1.017);
    opacity: 1;
    transition: .5s;
}

h2 {
    margin: 0px;
    background-color: rgba(255, 255, 255, 0.4);
    display: inline;
    border-radius: 5px;
    padding: 0px 2px;
    font-weight: 500;
}

.result p {
    margin: 3px 1px;
    font-size: 0.8em;
}

footer {
    color: white;
    text-align: right;
    margin-right: 20px;
    margin-bottom: 20px;
}
              
            
!

JS

              
                $(document).keypress(function (e) {
  if (e.which == 13) {
    Search();
  }
});

function Search(){
  if($("#search").val().length){
    $.ajax({
      method: "GET", 
      dataType: 'jsonp',
      contentType: 'application/json', 
      url:"https://en.wikipedia.org/w/api.php", 
      data:{
        action:"opensearch",
        search: $("#search").val(),  
        namespace:"0", 
        limit:"5",
        format:"json"       
      },
      success: function (data){
        var results = [];
        for(var i = 0; i < data[1].length; i++) {
          results.push({
            title: data[1][i],
            description: data[2][i],
            link: data[3][i]
          });
        }
        $("section").empty();
        results.forEach(function(item){
          var article = $("<article></article>");
          article.addClass("result");
          article.append("<h2>" + item.title + "</h2>");
          article.append("<p>" + item.description + "</p>");
          article.click({link: item.link}, openLink);
          $("section").append(article);
        });
      }
    });
  }

}

function openLink(event){
  window.open(event.data.link, '_blank');
}

              
            
!
999px

Console