I am trying to create a diagonal line on a webpage, to act as a section/section break. This is essentially a split colour section. I cant use an image as if the page gets enlarged, the image is going to pixelate. So i need to be able to draw a diagonal line directly at the bottom of the div, like the image below.
I have tried using a border, however i cannot get the actual break to be in the middle, rather than the right or left hand side.
Is there a way to draw diagonal lines in CSS? As you can see, i need to create a div that is 90px high and have the split/diagonal line in that div. I can then have a look at adding the image, but the main issue is not knowing whether this is possible with CSS.
if you want to put diagonal border in column you can do it this way and its 100% responsive. your requirement might be different though. I put it transparent image which contains white diagonal border in that section's right column.
https://codepen.io/neel555nc/pen/LgjoOg
You can do this without any clipping and just using borders in a unique way. This should also be cross-browser compatible, but I haven't tested it across everything
Initially divided this into 2 separate divs / triangles and joined them, but thanks to
web-tiki
andkaiido
perfected it to use only 1 div and minimal CSSOriginal Answer using multiple divs:
You can use CSS3
clip
:Demo: http://jsfiddle.net/zLkrfeev/2/
It's not widely supported by the browsers: http://caniuse.com/#feat=css-clip-path
With an svg, it is pretty simple :
Note that I used the
preserveAspectRatio="none"
attribute so that the shape can have 100% width and keep 90px heightAnd here with a monkey image :
You can do this using a gradient.
JSFiddle
Use a linear gradient