w3tweaks.com
  • Effects
    • Scroll Effects
    • Text Effects
    • Shadow
  • Essentials
    • Arrows
    • Buttons
    • Background Patterns
    • Border Examples
    • Cards
    • Color Palettes
    • Dividers
    • Link styles
    • Loaders
    • Modal Windows
    • Notifications
    • Progress bar
    • Quote styles
    • Spinner
    • Tooltips
  • Media
    • Calendars
    • Carousels
    • Clocks
    • Gallery
    • Music Players
    • Sliders
    • Slideshows
    • Tables
    • Thumbnails
  • Navigation
  • Inputs
    • Range Sliders
    • Checkboxes
    • Toggle Switches
  • Script
    • Angularjs
    • Backbone.js
    • bootstrap
    • jQuery
    • ReactJs
    • JavaScript
    • Syntax Highlighters
    • tryit editor
    • PHP
  • API’s
    • Facebook
    • Google
    • Indeed
    • Twitter
    • YouTube
  • Tools
w3tweaks.com
Home Essentials

Clipped Overlapping Grid Items

September 30, 2020
in Essentials

Hristovv demonstrates how `clip-path` can help build magazine-style photo layouts with CSS.

See the Pen Clipped overlapping grid items by hristov. (@hristovv) on CodePen.

You might also like

15 Free CSS Floating action buttons

13 Free CSS Ripple Effect Buttons

15 Inspiring Button Animation Examples with Demo: Elevate Your User Experience

Custom radio button using CSS only

T-shirt cannon playful animated button concept

Chat bubble smoothly morphs into a “close” X

Created on March 27, 2020 Updated on March 27, 2020. A Pen by hristov. on CodePen. License.

Download

index.html

<div class="row">
    <div class="box box--left">
        <div class="box__inner">
            <a href="#">
                <img src="https://source.unsplash.com/random/1024x600" alt="">
            </a>
        </div>
    </div>

    <div class="box box--right">
        <div class="box__inner">
            <a href="#">
                <img src="https://source.unsplash.com/random/1024x601" alt="">
            </a>
        </div>
    </div>

    <div class="box box--left box--small">
        <div class="box__inner">
            <a href="#">
                <img src="https://source.unsplash.com/random/1024x602" alt="">
            </a>
        </div>
    </div>

    <div class="box box--right box--small">
        <div class="box__inner">
            <a href="#">
                <img src="https://source.unsplash.com/random/1024x603" alt="">
            </a>
        </div>
    </div>
</div>
* {
    box-sizing: border-box;
}

.row {
    padding: 0.75vw;

    display: grid;
    grid-template-columns: repeat(64, 1fr);
    grid-template-rows: 55vh 30vh;
    grid-row-gap: 0.75vw;
}

.box a {
    display: block;
    width: 100%;
    height: 100%;

    position: absolute;
    top: 0;
    left: 0;

    &:hover img {
        opacity: 0.75;
    }
}

.box__inner {
    background-color: #005696;
    width: 100%;
    height: 100%;
    position: relative;

    img {
        width: 100%;
        height: 100%;

        object-position: 50% 50%;
        object-fit: cover;
        
        transition: opacity .2s ease-out;
    }
}

.box--left {
    clip-path: polygon(0 0, 98% 0, 83% 100%, 0 100%);
    grid-row: 1;
    grid-column: 1 / span 35;
}

.box--right {
    clip-path: polygon(17% 0, 100% 0, 100% 100%, 2% 100%);
    grid-row: 1;
    grid-column: span 35 / -1;
}

.box--small {
    grid-row: 2;
    
    &.box--left {
        clip-path: polygon(0 0, 83% 0, 98% 100%, 0 100%);
    }
    
    &.box--right {
        clip-path: polygon(2% 0, 100% 0, 100% 100%, 17% 100%);
    }
}   
* {
  box-sizing: border-box;
}

.row {
  padding: 0.75vw;
  display: grid;
  grid-template-columns: repeat(64, 1fr);
  grid-template-rows: 55vh 30vh;
  grid-row-gap: 0.75vw;
}

.box a {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}
.box a:hover img {
  opacity: 0.75;
}

.box__inner {
  background-color: #005696;
  width: 100%;
  height: 100%;
  position: relative;
}
.box__inner img {
  width: 100%;
  height: 100%;
  -o-object-position: 50% 50%;
     object-position: 50% 50%;
  -o-object-fit: cover;
     object-fit: cover;
  -webkit-transition: opacity .2s ease-out;
  transition: opacity .2s ease-out;
}

.box--left {
  -webkit-clip-path: polygon(0 0, 98% 0, 83% 100%, 0 100%);
          clip-path: polygon(0 0, 98% 0, 83% 100%, 0 100%);
  grid-row: 1;
  grid-column: 1 / span 35;
}

.box--right {
  -webkit-clip-path: polygon(17% 0, 100% 0, 100% 100%, 2% 100%);
          clip-path: polygon(17% 0, 100% 0, 100% 100%, 2% 100%);
  grid-row: 1;
  grid-column: span 35 / -1;
}

.box--small {
  grid-row: 2;
}
.box--small.box--left {
  -webkit-clip-path: polygon(0 0, 83% 0, 98% 100%, 0 100%);
          clip-path: polygon(0 0, 83% 0, 98% 100%, 0 100%);
}
.box--small.box--right {
  -webkit-clip-path: polygon(2% 0, 100% 0, 100% 100%, 17% 100%);
          clip-path: polygon(2% 0, 100% 0, 100% 100%, 17% 100%);
}
Tags: cardsgrid cards
Previous Post

CSS Neumorphic Toggle

Next Post

Masked & Skewed

Related Stories

CSS Floating action buttons
Essentials

15 Free CSS Floating action buttons

March 20, 2023
Free CSS Ripple Effect Button
Essentials

13 Free CSS Ripple Effect Buttons

March 6, 2023
15 Inspiring Button Animation Examples with Demo: Elevate Your User Experience
Essentials

15 Inspiring Button Animation Examples with Demo: Elevate Your User Experience

February 24, 2023
Pill Styled Radio ButtonsPill Styled Radio Buttons
Essentials

Custom radio button using CSS only

December 10, 2020
t-shirt cannon playful animated button concept
Essentials

T-shirt cannon playful animated button concept

October 13, 2020
chat bubble smoothly morphs into a "close" X
Essentials

Chat bubble smoothly morphs into a “close” X

October 13, 2020
Exciting Multi-line Highlights
Essentials

Exciting Multi-line Highlights

September 21, 2020
Stacked rainbow cards
Essentials

Stacked Rainbow Cards

July 9, 2020

Discussion about this post

Follow Us

Popular Posts

100 Creative CSS Cards

44 Free Multi step HTML forms

13 Free HTML & CSS Dashboard Template Designs

49 CSS Tables

20 HTML & CSS pricing tables

14 Best CSS Dark Mode

11 CSS Shopping Cart UI/UX

42 Cool CSS Avatars For Better UI

55 Useful handpicked CSS Buttons with examples and demos

89 Best CSS Toggle Switches

w3tweaks

We bring you the best frontend collections that will fix perfect for news, magazine, personal blog, etc. Check our landing page for details.

  • Effects
    • Scroll Effects
    • Text Effects
    • Shadow
  • Essentials
    • Arrows
    • Buttons
    • Background Patterns
    • Border Examples
    • Cards
    • Color Palettes
    • Dividers
    • Link styles
    • Loaders
    • Modal Windows
    • Notifications
    • Progress bar
    • Quote styles
    • Spinner
    • Tooltips
  • Media
    • Calendars
    • Carousels
    • Clocks
    • Gallery
    • Music Players
    • Sliders
    • Slideshows
    • Tables
    • Thumbnails
  • Navigation
  • Inputs
    • Range Sliders
    • Checkboxes
    • Toggle Switches
  • Script
    • Angularjs
    • Backbone.js
    • bootstrap
    • jQuery
    • ReactJs
    • JavaScript
    • Syntax Highlighters
    • tryit editor
    • PHP
  • API’s
    • Facebook
    • Google
    • Indeed
    • Twitter
    • YouTube
  • Tools