How to ensure the css border is inside the image
I have an image with an add frame with photoshop, but those borders are messy. I would overwrite this border without doing it again with photoshop (can't use the script because almost all images are too specific) because my client gave me about 15000 images with this error.
Then while I am about css border. So how can I make a border around the image to fill it?
Is it possible? Do you have an idea?
EDIT
List of ideas that don't work for my case:
- css attribute: border-style: inset (thank you Abdul Basit)
- css attribute: clip
Thanks in advance.
source to share
You can use box-shadow
c inset
to simulate a border. However, the box-shadow does not work directly on the image element because it will be displayed behind.
You can solve this by making class .image-wrapper
with box-shadow
on.
And to make this shadow render in front of your image, you just need to set z-index
to -1
.
* { box-sizing: border-box; }
.img-wrapper {
box-shadow: inset 0 0 0 20px red; // Fake border on the inside
display: block;
margin: 50px auto;
width: 90%;
}
.img-wrapper img {
display: block;
position: relative;
width: 100%;
z-index: -1; // Render the image behind the box-shadow
}
source to share