Pen Settings



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


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


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.


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.


                <p><a href="" target="_blank">There's an easier way of doing this using Grid.</a></p>
<h1> How to vertically align an image inside div using Flexbox</h1>
<div class="frame">
    <img src="">
<p>Demo for this question on Stack Overflow: <a href="" target="_blank">How to vertically align an image inside div</a></p>



                .frame {
    display: flex;
    Uncomment 'justify-content' below to center horizontally.
    ✪ Read below for a better way to center vertically and horizontally.

    /*justify-content: center;*/
    align-items: center;

img {
    height: auto;

    ✪ To center this image both vertically and horizontally,
    in the .frame rule above comment the 'justify-content' 
    and 'align-items' declarations,
    then  uncomment 'margin: auto;' below. 

    /*margin: auto;*/

/* Styles NOT needed for demo */
.frame {
    max-width: 900px;
    height: 200px;
    margin: auto;
    background: rgba(black, .3);
    border-radius: 3px;
    box-shadow: 0 2px 5px rgba(black, .1);
p {
    max-width: 900px;
    margin: 20px auto 0;
img {
    width: 150px;

/*  New tab icon 
.new-tab:after {
    display: inline-block;
    content: "⇱";
    position: relative;
    top: -5px;
    margin-left: 2px;
    transform: rotate(90deg);


    Script to improve UX of links that open a new tab
var tlinks = document.querySelectorAll("a[target=_blank]");
for (var x = 0; x < tlinks.length; x++) {
    tlinks[x].title = "Opens in new tab";
    var currentClass = tlinks[x].getAttribute("class");
    if (currentClass == null) currentClass = "";
    tlinks[x].setAttribute("class", currentClass + " new-tab");