I want shadow borders á la windows 10 around my moveable div elements. It can be done with box-shadow like
<style>
.box {
position: absolute;
top: 100px;
left: 100px;
width: 200px;
height: 200px;
cursor: move;
background-color: green;
box-shadow: 0px 0px 20px 10px #ccc;
}
.box2 {
left: 200px;
top: 200px;
background-color: blue;
}
</style>
<div class="box"></div>
<div class="box box2"></div>
Drawback is that the shadow is not a part of the div element in the same way as a border, so if you attach an event listener to the div to listen for mouseovers it won't detect any in the shadow area, but only when you move the mouse inside the element. In my (touch) application I'm letting the user move and resize the elements and therefore I need a rather wide touchable area around the element to facilitate the grabbing. A wide opaque border looks to clumsy for this in my opinion.
I've seen many examples of using border-images and linear gradients, however I haven't manage to mimic the look of box-shadows/windows 10 borders.
Is there any way to do this with border-images or in any other not overly complicated way?
inset
shadow. You may need extra tweaking to get it work the exact same way as a normal shadow but it doesn't need any extra elements. - Harry