1

How to draw cross diagonal lines without using SVG or HTML Canvas ?

My tutor hope we use simple CSS to make it.

loeghy10
  • 59
  • 1
  • 7

1 Answers1

2

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>
Jon Uleis
  • 17,693
  • 2
  • 33
  • 42