Diagonal with linear-gradient
css
.my-element {
background-image: linear-gradient(
to top right,
transparent calc(50% - 1px),
gray,
transparent calc(50% + 1px)
);
}