Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make half-square background in css

Tags:

css

css-shapes

square cut in half diagonaly

Is it possible to make in pure css background for half square like on the image. I know that it can be done with an image as background, but I need to use 5 different colours, and maybe in future the colours can be changed.

like image 659
jack wolier Avatar asked Apr 23 '15 09:04

jack wolier


People also ask

How do I get a 50 background color in CSS?

You can apply a background color to the html element, and then apply a background-image to the body element and use the background-size property to set it to 50% of the page width. This results in a similar effect, though would really only be used over gradients if you happen to be using an image or two.

How do you make a half background color in HTML?

Changing the opacity of the background color only To achieve this, use a color value which has an alpha channel—such as rgba. As with opacity , a value of 1 for the alpha channel value makes the color fully opaque. Therefore background-color: rgba(0,0,0,. 5); will set the background color to 50% opacity.

How do I create a polygon shape in CSS?

The polygon() function is an inbuilt function in CSS which is used with the filter property to create a polygon of images or text. Syntax: polygon( percentage | length); Parameter: This function accepts two parameter percentage or length which is used to hold the value of polygon size.


1 Answers

You can also try linear-gradient

div {
  width: 200px;
  height: 200px;
  background: rgba(248, 80, 50, 1);
  background:linear-gradient(to bottom right,grey 50%,red 50%);
}
<div></div>
like image 160
Akshay Avatar answered Oct 21 '22 21:10

Akshay