That’s because the starting and ending points of the gradient
are at the edges of the padding-box
and border
is rendered outside the padding-box
. So, the borders look funny because the background
is repeated on each side outside the padding-box
to cover the border-box
.
The box-shadow:inset
is rendered inside the padding-box
(just like background) and gives visually the same effect as a border
, so you could try using that in place of border
:
box-shadow: inset 0 0 0 10px rgba(0,0,0,0.2);
padding: 10px;
Because a box-shadow
doesn’t take up any space, you need to increase your padding accordingly.
Illustration of padding-box
and border-box
: