Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two-tone background split by diagonal line using css

I am trying to create a background using css where one side is a solid color and the other is a texture: the two are split by a diagonal line. I would like this to be 2 separate divs since I plan to add some motion with jQuery where if you click on the right, the grey triangle gets smaller and if you click on the left the textured triangle gets smaller (like a curtain effect). Any advice would be greatly appreciated.

Background split by diagonal line

like image 511
MG1 Avatar asked Feb 06 '13 21:02

MG1


People also ask

How do I make a background line diagonal in CSS?

From a CSS point of view, a diagonal line is nothing but a horizontal line which is rotated at +45 or -45 degrees angle. So, to draw a diagonal line in CSS, we have to simply rotate a normal horizontal line at an angle of + or – 45 degrees. The rotation in CSS is done using the transform property.

How do you make a half background color in HTML?

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.


1 Answers

I think using a background gradient with a hard transition is a very clean solution:

.diagonal-split-background{   background-color: #013A6B;   background-image: -webkit-linear-gradient(30deg, #013A6B 50%, #004E95 50%); } 
like image 199
Tom Bevelander Avatar answered Oct 05 '22 18:10

Tom Bevelander