-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
13 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
layout: layouts/post.njk | ||
title: 3D trailing shadows for images | ||
description: A simple trick to add a 3D shadow to your images | ||
date: 2023-07-04 | ||
tags: posts | ||
--- | ||
|
||
Add a 3D trailing shadow to your image with a few lines of code | ||
* No extra element (only the `<img>` tag) | ||
* No pseudo-element | ||
* Less than 10 CSS declarations | ||
* No scrollbar issue | ||
|
||
|
||
{% image "./image.png", "A 3D trailing shadow for images" %} | ||
|
||
```css | ||
img { | ||
--c: #CBE86B; /* the main color */ | ||
--t: 5px; /* thickness of the outline */ | ||
|
||
width: 200px; /* the image size */ | ||
aspect-ratio: 1; /* only square images, don't change this */ | ||
border-image: | ||
linear-gradient(45deg, | ||
color-mix(in srgb,var(--c),#000 20%) 50%, | ||
color-mix(in srgb,var(--c),#000 40%) 0) | ||
9999/9999px/9999px; | ||
clip-path: | ||
polygon(0 100%,0 0,100% 0, | ||
calc(100% + 9999px) 9999px, | ||
9999px calc(100% + 9999px)); | ||
outline: var(--t) solid var(--c); | ||
outline-offset: calc(-1*var(--t)); | ||
} | ||
``` | ||
|
||
<p class="codepen" data-height="450" data-default-tab="result" data-slug-hash="mdQwgMO" data-preview="true" data-user="t_afif" style="height: 450px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;"> | ||
<span>See the Pen <a href="https://codepen.io/t_afif/pen/mdQwgMO"> | ||
3D trailing shadow for images</a> by Temani Afif (<a href="https://codepen.io/t_afif">@t_afif</a>) | ||
on <a href="https://codepen.io">CodePen</a>.</span> | ||
</p> | ||
<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters