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

            
              mixin vintalight(img, description)
    figure.vintalight__container
        .vintalight__photo
            img(src=img, alt=description).vintalight__img
        figcaption.vintalight__caption
            h3.vintalight__text= description
            
section.vintalight#vintalight
    +vintalight("https://images.pexels.com/photos/69969/pexels-photo-69969.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb", "Happy Moment")
    +vintalight("https://images.pexels.com/photos/247929/pexels-photo-247929.jpeg?h=350&auto=compress&cs=tinysrgb", "Happy Moment")
    +vintalight("https://images.pexels.com/photos/92866/pexels-photo-92866.jpeg?h=350&auto=compress&cs=tinysrgb", "Happy Moment")
    +vintalight("https://images.pexels.com/photos/331986/pexels-photo-331986.jpeg?h=350&auto=compress&cs=tinysrgb", "Happy Moment")
    +vintalight("https://images.pexels.com/photos/296649/pexels-photo-296649.jpeg?h=350&auto=compress&cs=tinysrgb", "Happy Moment")
    +vintalight("https://images.pexels.com/photos/219776/pexels-photo-219776.jpeg?h=350&auto=compress&cs=tinysrgb", "Happy Moment")
 
// No olvides seguirme
.social-media
    a.social-media__link.social-media__link--twitter(href="https://twitter.com/Jopzik" target="_blank")
        span.social-media__icon.icon-twitter
        h3.social-media__user @Jopzik
    a.social-media__link.social-media__link--github(href="https://github.com/Jopzik/" target="_blank")
        span.social-media__icon.icon-github
        h3.social-media__user /Jopzik
    a.social-media__link.social-media__link--codepen(href="https://codepen.io/Jopzik/" target="_blank")
        span.social-media__icon.icon-codepen 
        h3.social-media__user /Jopzik
footer.footer-git
    p Ve este código en
        a(href="https://github.com/Jopzik/Vintalight" target="_blank")  Github 
            span.icon-github-alt
            
          
!

CSS

            
              // == Fuentes == //
@import url('https://fonts.googleapis.com/css?family=Nanum+Pen+Script|Roboto');

// == Variables == //
$size: 30px; // Tamaño
$resize: 0.7; // Redimencionamiento
$fig-width: 10.5em; // Ancho contenedor fotografía
$fig-height: 12.25em; // Alto contenedor fotografía
$photo-size: 9.25em; // Tamaño fotografía
$font-size: 1em; // Tamaño fuente
$font-view: "Roboto", sans-serif; // Fuente pseudo elemento
$font-description: 'Nanum Pen Script', cursive; // Fuente fotografía

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

// == Función para redimensionar en pantalla pequeña == //
@function resize($size-function) {
    @return $size-function * $resize;
}

// == Mixin media == //
@mixin media($screen: 500px) {
    @media screen and (max-width: $screen){
        @content;
    }
}

// == Mixin para posicionar y rotar fotografías == //
@mixin rotate($deg, $index, $transX, $transY) {
    transform: translate($transX, $transY) rotate($deg);
    z-index: $index;
    &:hover {
        transform: scale(1.15) translate($transX, $transY) rotate(0);
    }
    @include media(700px) {
        transform: translate(0) rotate($deg);
        &:hover {
            transform: scale(1.1) translate(0) rotate(0);
        }
    }
}

// == Estilos de body == //
/* Eliminar en producción */
body {
    display: flex;
    justify-content: center;
    width: 100%;
    background-color: #f2f2f2;
    overflow-x: hidden;
}

.vintalight {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    width: 90%;
    max-width: 1200px;
    padding: 50px 0;
    &__container {
        position: relative;
        width: 90%;
        max-width: $fig-width;
        height: $fig-height;
        background-color: #fff;
        font-size: $size;
        box-shadow: 0 2px 6px 1px rgba(#000, 0.5);
        transition: transform 0.5s cubic-bezier(0.075, 0.82, 0.165, 1), box-shadow 0.5s, margin 0.5s;
        @include media {
            max-width: resize($fig-width);
            height: resize($fig-height);
        }
        &:nth-child(1) {
            @include rotate(-30deg, 40, 40px, 30px);
        }
        &:nth-child(2) {
            @include rotate(7deg, 50, 30px, 20px);
        }
        &:nth-child(3) {
            @include rotate(20deg, 40, -20px, 20px);
        }
        &:nth-child(4) {
            @include rotate(10deg, 30, 40px, -10px);
        }
        &:nth-child(5) {
            @include rotate(-20deg, 20, 30px, -20px);
        }
        &:nth-child(6) {
            @include rotate(-10deg, 40, 30px, -40px);
        }
        &:hover {
            box-shadow: 0 4px 8px 3px rgba(#000, 0.4);
            z-index: 100;
            @include media(700px) {
                margin: 0 25px;
            }
            .vintalight__photo::before {
                transform: scale(1);
            }
        }
        &.active,
        &.active:hover {
            transform: rotate(0) scale(1.25);
            @include media {
                transform: rotate(0) scale(1.15);
            }
        } 
        &.active {
            position: relative;
            .vintalight__photo {
                cursor: default;
                &::before {
                    display: none;
                }
            }
        }
    }
    &__photo {
        position: relative;
        width: $photo-size;
        height: $photo-size;
        margin: (($fig-width - $photo-size) / 2) auto 0;
        @include media {
            width: resize($photo-size);
            height: resize($photo-size);
            margin: ((resize($fig-width) - resize($photo-size)) / 2) auto 0;
        }
        overflow: hidden;
        cursor: pointer;
        &::before {
            content: "Ver foto";
            display: flex;
            justify-content: center;
            align-items: center;
            position: absolute;
            width: 100%;
            height: 100%;
            background-color: rgba(#000, 0.5);
            color: #fff;
            font-size: $font-size;
            font-family: $font-view;
            transform: scale(0);
            transition: all 0.25s;
        }
    }
    &__img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    &__caption {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: ($fig-height - $photo-size) - (($fig-width - $photo-size) / 2);
        @include media {
            height: (resize($fig-height) - resize($photo-size)) - ((resize($fig-width) - resize($photo-size)) / 2);
        }
    }
    &__text {
        color: #222;
        font-size: $font-size;
        font-family: $font-description;
    }
    &-overlay {
        display: flex;
        justify-content: center;
        align-items: center;
        position: fixed;
        width: 100%;
        height: 100%;
        background-color: rgba(#000, 0.75);
        opacity: 0;
        z-index: 10000;
        transition: opacity 0.5s;
        &.active {
            opacity: 1;
        }
    }
    &__button {
        position: absolute;
        $size-button: 30px;
        top: ($size-button / -2);
        right: ($size-button / -2);
        width: $size-button;
        height: $size-button;
        background-color: hsl(0, 90, 60);
        border: 3px solid #fff;
        border-radius: 50%;
        outline: none;
        color: #fff;
        font-size: ($size-button / 2);
        font-weight: bold;
        box-shadow: -2px 2px 1px rgba(#000, 0.3);
        z-index: 10000;
        cursor: pointer;
    }
}
            
          
!

JS

            
              // Función que activa el overlay. Se pasa como parámetro el contenedor padre (#vintalight en el DOM)
const activeVintalight = container => {
    // Delegación de eventos para detectar click en los hijos
    container.addEventListener("click", e => {
        let element = e.target;
        // Validar que se haya dado click en el pseudoelemento before
        if (element.tagName == "DIV") {
            // Obtener dirección y descripción de la imagen que se dio click
            let src = element.querySelector("img").src,
                descrip = element.querySelector("img").alt,
                // Crear un nuevo div que se usará como overlay
                vintalightOverlay = document.createElement("div");
                // Agregar clase al div que creamos para poder darle estilos con CSS
                vintalightOverlay.classList.add("vintalight-overlay");
                // Agregar contenido al overlay 
            vintalightOverlay.innerHTML = `
                <figure class="vintalight__container active">
                    <div class="vintalight__photo">
                        <img src="${src}" alt="${descrip}" class="vintalight__img"/>
                    </div>
                    <figcaption class="vintalight__caption">
                        <h3 class="vintalight__text">${descrip}</h3>
                    </figcaption>
                    <button class="vintalight__button" id="button-close">✕</button>
                </figure>
            `;
            // Meter el overlay en el DOM
            document.body.appendChild(vintalightOverlay);
            // Añadimos la clase active para poder darle transición
            setTimeout(() => {
                vintalightOverlay.classList.add("active");
            }, 1);
            // Eliminar el scroll del body
            document.body.style.overflow = "hidden";
            // Evento para cerrar el overlay
            document.getElementById("button-close").addEventListener("click", () => {
                // Eliminar clase active
                vintalightOverlay.classList.remove("active");
                // Eliminar overlay del DOM
                setTimeout(() => {
                    document.body.removeChild(vintalightOverlay);
                }, 500);
                // Devolver scroll al body
                document.body.style.overflow = "auto";
            });
            // Evento para cerrar el overlay con la tecla ESC
            window.addEventListener("keyup", e => {
                if (e.key === "Escape") document.getElementById("button-close").click();
            });
        }
    });
}

// Activamos la función
window.addEventListener("load", activeVintalight(document.getElementById("vintalight")));
            
          
!
999px

Console