- This topic is empty.
Viewing 13 posts - 1 through 13 (of 13 total)
Viewing 13 posts - 1 through 13 (of 13 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
What I’d like to achieve is fairly simplistic. I’d like to have an image with a 15px border and a shadow around the image. However, I’d like that shadow to be around the image itself, not outside the border.
Is this possible without an additional DIV wrapping around the image? I feel like this is a “Let me Google that for you…” question, but I’ve been unable to find an answer in searches.
> Is this possible without an additional DIV wrapping around the image?
No, it’s not possible (for now). At least, as far as I know, maybe someone has something creative up their sleeve. But I’d say your best bet without extra markup would be a pseudo-element, which isn’t (currently) supported for the `img` tag. See [this spec](http://www.w3.org/TR/CSS2/generate.html#before-after-content “”).
What would be the purpose/effect of the shadow? Is this a box-shadow/drop-shadow?
I’m having a tough time visualising this.
Yeah…I get what you are trying to do…but I’m having trouble visualising how this would actually look.
Do you have something (mock-up image perhaps) we could look at?
http://codepen.io/Merri/pen/GLwes
Can’t do it with only the image element as you can’t have pseudo elements for it.
**Edit!**
But this you can do:
img {
background: red;
border-radius: 3em;
box-shadow: inset 0 0 1em black;
padding: 1em;
}
It might not be what you want, but it works.
How about a complex background-image gradient?
merris solution in action…
http://codepen.io/karimcossutti/pen/eFgBx
for what i understand this is what you want to achieve right?
http://codepen.io/wolfcry911/pen/EFbjL
as merri pointed out, you can’t use pseudo elements :before or :after on img, but you could accomplish this using a background image on a different element.
It is possible if you think of the border as another box-shadow ;)
good one Croco
Very nice, @CrocoDillon
Thnx ^^ @siouxfan45, yeah agree on the not well documented part (JS is even worse…) Good luck!
Props to Croc, nice simple solution.