My goal is to add an element on all four sides of the div without using box-sizing. The challenge is that I need to apply event listeners to these elements once they are placed.
Currently, I can add elements to the left and right sides, but I'm struggling to figure out how to position them on all four sides in a more elegant way.
.box {
width: 100px;
height: 100px;
background: yellow;
text-align: center;
font-size: 0.8rem;
position: relative;
}
#sideEl {
background-color: red;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 4px;
height: 100%;
cursor: w-resize;
}
#sideEl2 {
background-color: red;
position: absolute;
right: 0;
bottom: 0;
width: 4px;
height: 100%;
cursor: w-resize;
}
<div class="box">
<div id="sideEl">
<div id="sideEl2">
</div>
https://i.sstatic.net/Um0KM.png
I came across a post about Placing 4 html elements in every corner of a div, but I haven't found a solution yet for placing them along all sides of the borders.