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. 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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

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.

              <!-- FONTS -->
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>

<!-- PAGE STUFF -->
<input type="checkbox" id="menuCheckbox"/>
<input type="checkbox" id="searchCheckbox"/>

<div class="photo-container">
    <div class="close">close</div>
    <div class="photo-details">
        <h2>Photo Details</h2>
            <li class="rela-inline"><span>PUBLISHED : </span> Jan 1, 1980</li>
            <li class="rela-inline"><span>DIMENSIONS : </span>9999 x 9999</li>
            <li class="rela-inline"><span>MAKE : </span>Canon</li>
            <li class="rela-inline"><span>MODEL : </span>Canon EOS 6D</li>
            <li class="rela-inline"><span>EXPOSURE TIME : </span>0.004</li>
            <li class="rela-inline"><span>APERTURE : </span>5</li>
            <li class="rela-inline"><span>FOCAL LENGTH : </span>178</li>
            <li class="rela-inline"><span>ISO : </span>100</li>
    <div class="abs-center photo-tab"></div>

<div class="side-menu">
    <label for="menuCheckbox" class="checkbox-label side-menu-label">
        <div class="abs-center white-x"></div>
    <div class="rela-block menu-content">
        <h3 class="rela-block list-header">Browse</h3>
        <ul class="rela-block options-list">
        <h3 class="rela-block list-header">Explore</h3>
        <ul class="rela-block options-list">
            <li>Made with Unsplash</li>
            <li>Tagged Photos</li>
            <li>Submit a Photo</li>
    <div class="social-buttons-container">
        <div class="rela-inline social-button twitter"></div>
        <div class="rela-inline social-button facebook"></div>
        <div class="rela-inline social-button pinterest"></div>
        <div class="rela-inline social-button instagram"></div>

<div class="rela-block top-bar"><a href="https://codepen.io/mavrK/" class="link">Made by one cool dude</a></div>

<div class="rela-block top-container">
    <div class="rela-block top-center-container">
        <div class="inner-container top-text-container">
            <h2 class="rela-block top-main-text">Unsplash</h2>
            <p>Free High-resolution images every ten days.</p>
            <div class="rela-inline button white-text">Subscribe</div>
        <div class="inner-container top-search-container">
            <p class="search-text">Search Unsplash</p>
            <input type="text" placeholder="Type Something" class="top-search"/>
    <label for="menuCheckbox" class="checkbox-label menu-label">
        <div class="abs-center black-lines"></div>
    <label for="searchCheckbox" class="checkbox-label search-label">
        <div class="abs-center magnifying-glass"></div>

<div class="rela-block image-layout-selector">
    <div class="floated layout-option rows">
        <div class="abs-center bars rotated"></div>
    <div class="floated layout-option columns active">
        <div class="abs-center bars"></div>

<div class="rela-block image-grid-container">
    <div class="floated image-column 1">
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
    <div class="floated image-column 2">
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
    <div class="floated image-column 3">
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>
        <div class="rela-block image"></div>

<div class="rela-block button black-text load-button">Load More</div>

              // MIXINS
// Dummy Variable
$x = false;
// The top, left, right, and bottom are optional
setup(display, position, margin, top = null, right = null, bottom = null, left = null)  
    display display
    position position
    margin margin
    if position == "absolute" || "fixed"
        top top
        left left
        right right
        bottom bottom
font(font-family, font-size, letter-spacing, font-weight, line-height = null)
    font-family font-family
    font-size font-size
    letter-spacing letter-spacing
    font-weight font-weight
    line-height line-height
* {box-sizing: border-box; transition: 0.333s ease;}
    setup(block, relative, auto)
    setup(inline-block, relative, auto)
    setup(inline-block, relative, $x)
    float left
    setup($x, absolute, $x, 50%, $x, $x, 50%)
    transform translate(-50%, -50%)
    text-align center
    width 88%
// --- PAGE STYLINGS ---
    font("Open Sans", 18px, 2px, 400, 24px)
    background-color #ECECEC
    transition 0s
    z-index -1
    opacity 0
    background-color rgba(0,0,0,0.73)
    &.displayed {z-index: 200; opacity: 1;}
    &.displayed .photo-tab {top: 45%}
    &.displayed .photo-details {bottom: 4%; transition: 0.35s ease, bottom 0.35s 0.35s ease}
    & .close {color: white; margin: 30px; cursor: pointer;}
    transform translateX(-50%)
    color white
    width 60%
    max-width 700px
    font("Open Sans",14px,2px,300,24px)
    & h2 {font("Montserrat",18px,4px,400,30px); text-transform: uppercase;}
    & ul {text-align: justify; margin-left: -15px}
    & li {margin: auto 15px}
    & span {font-weight: 600}
    z-index 300
    top 55%
    width 50%
    padding-bottom 50%
    margin auto
    background-size contain !important
    background-position center !important
    z-index 100
    setup($x, fixed, $x, 0, $x, 0, -360px)
    width 360px
    background-color #1A1A1A
    padding-top 80px
    color #888
    margin-bottom 10px
    padding-left 30px
    margin-bottom 40px
    & li
        height 50px
        color #CCC
        line-height 50px
        padding-left 30px
        transition 0.15s ease
        cursor pointer
        &:hover {background-color: rgba(255,255,255,0.2); color: #FFF}
    setup($x, absolute, $x, $x, 0, 0, 0)
    height 60px
    text-align center
    height 55px
    width 55px
    margin 0 5px
    background-size cover !important
    transform scale(0.75)
    cursor pointer
        background url('https://cdn2.iconfinder.com/data/icons/black-white-social-media/32/twitter_online_social_media-128.png') no-repeat center
        background url('https://cdn2.iconfinder.com/data/icons/black-white-social-media/32/online_social_media_facebook-128.png') no-repeat center
        background url('https://cdn2.iconfinder.com/data/icons/black-white-social-media/32/online_social_media_pinterest-128.png') no-repeat center
        background url('https://cdn2.iconfinder.com/data/icons/black-white-social-media/32/instagram_online_social_media_photo-128.png') no-repeat center    
        transform scale(1)
        transition 0.3s cubic-bezier(0.3, 0.2, 0, 2.5)
    z-index 5
    height 200px
    background-color #1A1A1A
    text-align center
    overflow hidden
    & .link
        position relative
        font-size 14px
        letter-spacing 0
        top 30px
        text-decoration none
        color #999
    z-index 101
    height 40px
    width 40px
    cursor pointer
        height 100%
        font("Open Sans", 18px, 0px, 600, 24px)
        color black
        opacity 0
        transition 0.25s ease
    &:hover:after {opacity: 1}
    &.side-menu-label {opacity:1; setup($x,absolute,$x,20px,20px)}
        setup($x, absolute, $x, 20px, $x, $x, 20px)
        &:after{content: "MENU"; setup($x, absolute, $x, 20%, $x, $x, 45%)}
        &:hover:after{left: 100%}
        setup($x, absolute, $x, 20px, 20px)
        &:after{content: "SEARCH"; setup($x, absolute, $x, 20%, $x, $x, -100%)}
        &:hover:after{left: -170%}
    height 2px
    width 18px
    background-color #222
    left 40%
    &:before, &:after
        content ""
        position absolute
        left 0
        height 2px
        width 26px
        background-color #222
        transition 0.2s ease
    &:before {top: -7px}
    &:after {top: 7px}
    height 32px
    width 36px
        content ""
        setup($x, absolute, $x, 3px, $x, $x, 3px)
        height 16px
        width 16px
        border 2px solid #222
        border-radius 100%
        transform rotate(45deg)
        content ""
        setup($x, absolute, $x, $x, 10px, 3px)
        height 12px
        width 2px
        background-color #222
        transform rotate(-49deg)

    height 40px
    width 40px
    &:before, &:after
        content ""
        setup($x, absolute, $x, 50%, $x, $x, 50%)
        height 2px
        width 26px
        background-color white
    &:before{transform: translate(-50%, -50%) rotate(-45deg)}
    &:after{transform: translate(-50%, -50%) rotate(45deg)}
input[type=checkbox] {display: none}
#menuCheckbox:checked ~ .side-menu{left: 0; box-shadow: 2px 0px 18px 0px rgba(0,0,0,0.5)}       
    &~ .top-container .top-center-container
        & .top-text-container {left: -100%}
        & .top-search-container {left: 0}

    z-index 10
    height 200px
    width 88%
    max-width 1200px
    padding-top 25px
    margin -100px auto 50px
    background-color white
    text-align center
    box-shadow 0px 3px 12px 0px rgba(0,0,0,0.2)
    & p {color: #777; margin: 0 auto 25px}
    & h2 {color: #2B2B2B; margin: 0 auto 12px}
    height 190px
    width 84%
    overflow-x hidden
    width 100%
    overflow hidden
    setup($x, absolute, $x, 0, $x, 0, $x)
        left 0
        transition 0.4s ease
        left 100%
        transition 0.4s ease
        & .search-text
            setup($x, absolute, $x, 0, $x, $x, 40px)
            font("Open Sans", 16px, 0, 600, 20px)
            color #2B2B2B
    setup(block, relative, 25px auto)
    font("Open Sans", 44px, 0, 600, 70px)
    height 70px
    width 85%
    padding 0 20px
    color #2B2B2B
    border none
    border-bottom 2px solid #999
    &:focus {outline: none; border-bottom: 2px solid #2B2B2B}
.top-main-text{text-transform: uppercase; font("Open Sans", 24px, 5px, 600, 30px)}
    font("Open Sans", 16px, 0px, 400, 30px)
    $buttonColor = #2B2B2B;
    margin 0 auto 25px
    width 180px
    padding 8px
    border 1px solid $buttonColor
    cursor pointer
    text-align center
        color white
        background-color $buttonColor
            color $buttonColor
            background-color transparent
        color $buttonColor
        background-color transparent
            color white
            background-color $buttonColor
        border-width 4px
        font-weight 600
        margin-bottom 50px
    margin-bottom 50px
    height 50px
    width 100px
    & .layout-option
        height 100%
        position relative
        width 50%
        cursor pointer
        &.active .bars
            &:before, &:after {background-color: #1A1A1A}
    height 60%
    width 60%
    &:before, &:after
        content ""
        background-color #999
        transition 0.3333s ease
    &:before {color:black; setup($x, absolute, $x, 0, 60%, 0, 0)}
    &:after {color: black; setup($x, absolute, $x, 0, 0, 0, 60%)}
    &.rotated {transform: translate(-50%, -50%) rotate(90deg)}
    margin-bottom 40px
    height auto
    width 88%
    max-width 1200px
    overflow hidden
    position relative
    width 33.3333333%
    text-align center
    &.rows {width: 100%}
    &.rows .image {padding-top: 50%; margin-bottom: 60px}
    width 88%
    margin-bottom 30px
    box-shadow 0px 8px 25px -5px rgba(0,0,0,0.5)
    background-repeat no-repeat !important
    background-position center !important
    background-size cover !important
    cursor pointer
    &.wide {padding-top: 50%;}
    &.square {padding-top: 80%;}
    &.long {padding-top: 110%;}
    &.wide:before {padding-top: 25%;}
    &.square:before {padding-top: 42%;}
    &.long:before {padding-top: 59%;}
        content "View Image"
        setup($x, absolute, $x, 0, 0, 0, 0)
        color white
        opacity 0
        background-color rgba(0,0,0,0.7)
        transition 0.33333s ease
@media screen and (min-width:1400px)
    .photo-tab {padding-bottom: 45%; width 45%;}

@media screen and (max-width:629px)
    .photo-details {width: 88%}
    .photo-tab {padding-bottom: 80%; width 80%;}
    .top-container {height: 220px}
    .top-center-container{width: 75%}
    .top-search{height: 50px; font("Open Sans", 32px, 0, 600, 50px)}
    .image-layout-selector{height: 0; margin-bottom: 0}
    .image-column{width: 100%}
    .image-column .image{padding-top: 50%; margin-bottom: 40px}
@media screen and (max-width:500px)
    .top-search {height: 36px; font("Open Sans", 20px, 0, 600, 36px)}

              // Pinspiration
// https://www.behance.net/gallery/35580657/Unsplash-Website-Redesign

// Array for feed images
var imgArray = ['https://ribbonaroundabomb.files.wordpress.com/2013/06/hipster-art-three-of-the-possessed.jpg',

// Loop for placing the images into the divs on the page
for(var i=0;i<imgArray.length;i++) {

    // Changing height to width ratio of div based on the ratio of the image - SIZING NOT WORKING 100%
    var img = new Image();
    img.src = imgArray[i];
    if((img.width / img.height) > 1.2) {$('.image').eq(i).addClass('wide')}
    else if((img.width / img.height) < 0.8333) {$('.image').eq(i).addClass('long')}
    else {$('.image').eq(i).addClass('square')}; // Fallback to normal square

    // Setting the Background image
    $('.image').eq(i).css('background-image', 'url("'+imgArray[i]+'")');

// Load More images function - NOT WORKING PROPERLY WITH THE SIZING
    for(var j = 1; j < 4; j++){
        var imageNum = $('.image').length; // Getting total number of images on the page.

        for(var i = 1; i < 4; i++){
            var thisImageNum = imageNum + i;
            $('.image-column.'+i).append('<div class="rela-block image '+thisImageNum+'"></div>'); 

            var img = new Image();
            img.src = imgArray[thisImageNum - 1];
            if((img.width / img.height) > 1.2) {$('.image.'+thisImageNum).addClass('wide')}
            else if((img.width / img.height) < 0.8333) {$('.image.'+thisImageNum).addClass('long')}
            else {$('.image.'+thisImageNum).addClass('square')};

            // Setting the Background image
            $('.image.'+thisImageNum).css('background-image', 'url("'+imgArray[thisImageNum - 1]+'")');
    return false;

// Image Layout Switching Function
    return false;

// Display Image function
// Click function written this way due to dynamically added images
$('.image-grid-container').on('click', '.image', function() {
    // get the url image clicked
    var thisBG = $(this).css('background-image');
    //assign background to the pop-up and display
    $('.photo-tab').css('background',thisBG+' center no-repeat');
    return false;

// closing the menu-overlay
$('.close, .photo-container').click(function(){ 
    $('.photo-container').removeClass('displayed'); return false;
// preventing clicks on the menu closing it for now because there is nothing inside yet.
$('.photo-tab').click(function(){ return false; }); 
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.