TL;DR: I've been trying to add a white inset box shadow to highlight the bottom of a div in nav. When resizing the page, as the nav resizes, 1px white borders appeared on the left and right sides of the div even though they shouldn't. These left and right borders did not show up while the div was at full size. (images posted below)
How should I be getting rid of these left and right borders and why does this occur? (currently am using clip-path to trim the sides off the div)
I've been trying to add a colored highlight of sorts to the bottom of divs on my navbar. My approach for this has been to add inset box shadows to these divs as follows:
.div {
/* using black for this example */
box-shadow: inset 0 -0.25rem black;
padding: 1rem;
display: inline-block;
}
<div class="div">A div</div>
This seems to achieve what I want, but for some reason, whenever I try shrinking the page in responsive mode or viewing the page on mobile, I can see 1px wide white borders on the left and right edges of the div that go away when I either disable the box shadow or replace the 0
horizontal offset above with a non-zero value.
These side borders also only appear at when resizing the page and reducing the width to the point where the nav items start to shrink. They also seem to continuously appear and disappear as I resize the page, sometimes only on the left or right.
Here's a screenshot I captured with the page width reduced in responsive mode, where the shadow can be seen on both edges:
And here's what it normally looks like:
My solution to avoid this was to add a clip path to the div to trim the left and right edges, but I was hoping to understand why these even showed up in the first place and only when resizing the page. And is there a better way to fix this instead of trimming the edges of the div off?