Reputation: 59
How to draw cross diagonal lines without using SVG or HTML Canvas ?
My tutor hope we use simple CSS to make it.
Upvotes: 1
Views: 1162
Reputation: 18639
Here's two diagonal lines forming an X using only CSS and one element.
.x {
width: 100px;
height: 100px;
position: relative;
}
.x::before,
.x::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-right: 1px solid #000;
}
.x::before {
transform: rotate(45deg) translate(-50px, 0);
}
.x::after {
transform: rotate(-45deg) translate(-50px, 0);
}
<div class="x"></div>
Upvotes: 2