|
|
|
|
|
by chrismorgan
1837 days ago
|
|
> Try covering dynamic-sized image with an svg surface. This isn’t difficult. Two reasonable approaches immediately occur to me on this. ① The traditional one: <div style=position:relative;display:inline-block><img><svg style=position:absolute;inset:0 /></div> ② Using Grid’s ability to put multiple things in the one cell: <div style=display:grid><img style=grid-row:1;grid-column:1><svg style=grid-row:1;grid-column:1 /></div> > Try outlining a hovered element so that outline/shadow covers other items around. On hover, ensure it’s on a layer of its own, and if its surrounds are also on layers bump its z-index above theirs. e.g. `:hover { position: relative; z-index: 1 }`. Definitely hacky, but not difficult, unless you want the decoration to render beyond the bounds of a parent element’s layer, such as if it’s in a scrolling area with 0.5em of padding and you want a 1em box-shadow around it—that simply can’t be done, layers are inviolate; but as consolation, other platforms almost certainly have the same limitation. |
|
It indeed is [1].
Expected: a yellow line crossing an entire 236x236 image, in all three cases.
Explanation: svg default size is lunatic (300x150) and it doesn't care of your layout modes, so it clips all drawing beyond that, unless you specify either width/height attributes (not css properties!), or a viewBox, from which it infers missing width/height.
I lost a day to this once, when parent-filling svg clipped 3 of my 5 shapes for no fucking reason. Shapes coincidentally fell either fully into 300x150 box or fully outside of it -- no easy hint for you.
You can pre-calculate that in js, but if you specify .wrapper's dimensions in non-px, or use some aspect fit, you're screwed as well.
[1] https://codepen.io/mhmdqrn/pen/yLMvGJW