CSS image reflections with box-reflect

Did you know CSS has a custom reflection property?
It’s a pretty cool addition to reflect an image to a specific side.

We can create these reflections using the box-reflect property.

Curious to see what the reflection can look like, check out this Co…


This content originally appeared on DEV Community and was authored by Chris Bongers

Did you know CSS has a custom reflection property?
It's a pretty cool addition to reflect an image to a specific side.

We can create these reflections using the box-reflect property.

Curious to see what the reflection can look like, check out this Codepen using box-reflect.

Reflecting image using CSS

For our example, we are using a super simple markup using just one image.

<img src="myimage.png" />

Then we can use the box-reflect class to enable our reflection:

img {
  -webkit-box-reflect: below;
}

This will give us the following result:

CSS Box-reflect below

We can use the following options:

  • below
  • above
  • left
  • right

And even place a offset:

img {
  -webkit-box-reflect: right 20px;
}

Box-reflect offset right

And even cooler, we can add a gradient as the fade-out effect using the third parameter.

img {
  -webkit-box-reflect: below 0px linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.4));
}

Browser support

Box-reflect doesn't have the best support, but it's upcoming. So far, Firefox and IE have no support at all.

CSS Box-reflect browser support

Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter


This content originally appeared on DEV Community and was authored by Chris Bongers


Print Share Comment Cite Upload Translate Updates
APA

Chris Bongers | Sciencx (2021-03-14T12:11:47+00:00) CSS image reflections with box-reflect. Retrieved from https://www.scien.cx/2021/03/14/css-image-reflections-with-box-reflect/

MLA
" » CSS image reflections with box-reflect." Chris Bongers | Sciencx - Sunday March 14, 2021, https://www.scien.cx/2021/03/14/css-image-reflections-with-box-reflect/
HARVARD
Chris Bongers | Sciencx Sunday March 14, 2021 » CSS image reflections with box-reflect., viewed ,<https://www.scien.cx/2021/03/14/css-image-reflections-with-box-reflect/>
VANCOUVER
Chris Bongers | Sciencx - » CSS image reflections with box-reflect. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/14/css-image-reflections-with-box-reflect/
CHICAGO
" » CSS image reflections with box-reflect." Chris Bongers | Sciencx - Accessed . https://www.scien.cx/2021/03/14/css-image-reflections-with-box-reflect/
IEEE
" » CSS image reflections with box-reflect." Chris Bongers | Sciencx [Online]. Available: https://www.scien.cx/2021/03/14/css-image-reflections-with-box-reflect/. [Accessed: ]
rf:citation
» CSS image reflections with box-reflect | Chris Bongers | Sciencx | https://www.scien.cx/2021/03/14/css-image-reflections-with-box-reflect/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.