[css] draw diagonal lines in div background with CSS

Here is how I did this using the css clip-path property alongside relative and absolute positioning to create a more fancy cross.

_x000D_
_x000D_
.cross {_x000D_
  width:150px;_x000D_
  height: 150px;_x000D_
  border: 2px solid #555;_x000D_
  border-radius: 5px;_x000D_
  position: relative;_x000D_
  background: #efefef;_x000D_
}_x000D_
_x000D_
.cross .diag1{_x000D_
  position: absolute;_x000D_
  width:100%; height:100%;_x000D_
  clip-path: polygon(90% 0, 100% 0%, 10% 100%, 0% 100%);_x000D_
  background: #311B92;_x000D_
}_x000D_
_x000D_
.cross .diag2{_x000D_
  position: absolute;_x000D_
  width:100%; height:100%;_x000D_
  clip-path: polygon(0 0, 10% 0, 100% 100%, 90% 100%);_x000D_
  background: #1B5E20;_x000D_
}
_x000D_
<div class="cross">_x000D_
  <div class="diag1"></div>_x000D_
  <div class="diag2"></div>_x000D_
</div>
_x000D_
_x000D_
_x000D_

Here is a link to the code on codepen if you'd like to tweak it.

Examples related to css

need to add a class to an element Using Lato fonts in my css (@font-face) Please help me convert this script to a simple image slider Why there is this "clear" class before footer? How to set width of mat-table column in angular? Center content vertically on Vuetify bootstrap 4 file input doesn't show the file name Bootstrap 4: responsive sidebar menu to top navbar Stylesheet not loaded because of MIME-type Force flex item to span full row width

Examples related to background

SwiftUI - How do I change the background color of a View? Changing background color of selected item in recyclerview Android Studio Image Asset Launcher Icon Background Color Android: keep Service running when app is killed How to set a background image in Xcode using swift? CSS Background image not loading css transition opacity fade background how to set the background image fit to browser using html background:none vs background:transparent what is the difference? How to scale images to screen size in Pygame

Examples related to line

How do I compute the intersection point of two lines? Java Replace Line In Text File draw diagonal lines in div background with CSS How to make a new line or tab in <string> XML (eclipse/android)? How do you run a command for each line of a file? How can I format a list to print each element on a separate line in python? Remove lines that contain certain string How to paste text to end of every line? Sublime 2 Making PHP var_dump() values display one line per value How to do multiple line editing?

Examples related to css-shapes

How to create a inner border for a box in html? CSS Circle with border How to Make A Chevron Arrow Using CSS? How to make a div with a circular shape? How to make rectangular image appear circular with CSS Half circle with CSS (border, outline only) How to draw a checkmark / tick using CSS? how to draw a rectangle in HTML or CSS? CSS3 Transform Skew One Side Center Triangle at Bottom of Div

Examples related to diagonal

draw diagonal lines in div background with CSS