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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="main-container">
    <div class="sidebar growing-children">
        <div class="controller-container">
            <div class="random-container flex-item">
                <button data-address="https://stuff.com" class="random-button btn big-text">Random Article</button>
            </div>
            <div class="search-container flex-item">
                <div class="search-text-container">
                    <input id="search-field" class="btn big-text" type="text" name="search-term" placeholder="Search Term" value="">
                </div>
            </div>
        </div>
    </div>
    <div class="result-container growing-children"></div>
</div>
              
            
!

CSS

              
                html, body {
    height:100% !important;
    margin: 0;
    background-color: beige;
}

.sidebar {
    /*background-color: #333;*/
    display: flex;
}

.flex-item {
    flex-shrink: 1;
}



.controller-container {
    display: flex;
}

.main-container {
    display: flex;
}

.result {
    border-radius: 5px;
    border: solid black 2px;;
    margin: 5px;
    padding: 2px;
}

.result a div {
    color: black;
}

.result a {
    text-decoration: none;
}

#search-field {
    cursor: text;
}

.big-text {
    text-transform:uppercase;
    font-weight: bold;
}

.result-container {
    overflow: auto;
}

@media (max-width: 1120px) {
    .main-container {
        flex-direction: column;
        justify-content: space-around;
    }
    
    .controller-container {
        flex-direction: row;
        top: 20px;
        position: absolute;
    }
    
    .sidebar {
        border-bottom: solid black 5px;
        min-height: 10vh;
    }
}

@media (min-width: 1121px) {
    
    .controller-container {
        flex-direction: column;
    }

    .random-button {
        margin-bottom: 10px;
    }
    
    .main-container {
        flex-direction: row;
    }
    
    .result-container {
        display: block;
        height: 100vh;
    }
    
    .growing-children {
        flex-grow: 1
    }
    
    .sidebar {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-width: 20%;
        height: 100vh;
        max-width: 20%;
        border-right: solid #222;
    }
    
}
              
            
!

JS

              
                $(document).ready(function() {
    $(".random-button").click(function() {
        window.open("https://en.wikipedia.org/wiki/Special:Random"); 
    });
    
    $("#search-field").on("keyup", function(e) {
        if (e.keyCode === 13 || e.charCode === 13) {
            getWikipediaJson($(this).val());
        }
    });
});

var getWikipediaJson = function(term) {
    axios.get(getApiLink(term))
    .then(function(response) {
        handleResults(response.data.query.search);
    })
    .catch(console.error);
}

var getApiLink = function(searchTerm) {
    return `https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch=${searchTerm}&origin=*`;
}

var handleResults = function(results) {
    var resultItems = [];
    results.forEach(function(result) {
        resultItems.push(buildResultItem(result.title, result.snippet));
    });
    console.log("Setting results");
    $(".result-container").html(resultItems);
}

var buildResultItem = function(title, previewText) {
    return "<div class='result'><a href='https://en.wikipedia.org/wiki/" + title + "' target='popup'><div><h3>" + title + "</h3><br><p>" + previewText + "</p></div></a></div>";
}
              
            
!
999px

Console