Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I just use the fact that a DOM-Element with two different border for top and right results in a diagonal line where both meet. Then put the height and width of the DOM-Element to zero and set the border-top-width to window-height and the border-right-width to window-width. Update it with JavaScript on resize... That's all.</p> <p>I've put a container in the DOM</p> <pre><code>&lt;div id="diagonal_outer"&gt;&lt;div id="diagonal"&gt;&lt;/div&gt;&lt;/div&gt; </code></pre> <p>Following CSS is nessesary</p> <pre><code>div#diagonal_outer { position: fixed !important; position: absolute; overflow: hidden; left: 0; top: 0; right: 0; bottom: 0; z-index: -100; } div#diagonal { position: relative; border-color: #FAE9E1 #ffffff; border-style: solid; border-left-width: 0; border-top-width: 10240px; border-right-width: 12800px; border-bottom-width: 0; height: 0; width: 0; left: 50%; top: 50%; margin-left: -6400px; /* half of border-right-width */ margin-top: -5120px; /* half of border-top-width */ z-index: -100; } </code></pre> <p>and following JavaScript to actualize on resize</p> <pre><code>jQuery(document).ready(function() { diagonal(); }); jQuery(window).resize(function() { diagonal(); }); var diagonal = function() { var wWidth = jQuery(window).width(); var wHeight = jQuery(window).height(); jQuery('#diagonal').css('left', 0); jQuery('#diagonal').css('top', 0); jQuery('#diagonal').css('margin-left', 0); jQuery('#diagonal').css('margin-top', 0); jQuery('#diagonal').css('border-right-width', wWidth); jQuery('#diagonal').css('border-top-width', wHeight); }; </code></pre> <p>OK, the solution with <strong>CSS-skew</strong> is nice, but this one works with CSS &lt;3</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload