- This topic is empty.
August 28, 2011 at 6:10 am #85856January 13, 2012 at 11:53 am #94534erikportinMember
I think I’ll go for an image instead…November 12, 2012 at 6:58 am #114008Historical Forums UserParticipant
Stumbled upon this when I googled the same issue:)
A technique i’m just playing with is using SVG as background image.:
-o-background-size: 100% 100%;
-webkit-background-size: 100% 100%;November 12, 2012 at 9:13 am #114016JoniGiuroParticipant
Here’s my attempt:
It only works for chrome for now, because I was too lazy to add all the prefixes in the js and css.
scrW = $(window).width();
scrH = $(window).height();
angle = (Math.atan(scrH / scrW)) * (180/3.14);
var line = $(‘#line’);
var length = Math.sqrt(( scrW * scrW) + (scrH * scrH ));
line.css(‘left’, ( -1 ) * ((length – scrW) / 2) );
line.css(‘top’, scrH / 2);
line.css(“-webkit-transform”, “scale(1) rotate(” + (-1) * angle + “deg) translateX(0px) translateY(0px) skewX(0deg) skewY(0deg)”);December 6, 2012 at 1:34 pm #116540Rob WierzbowskiParticipant
If you’re ok with a css3 requirement, you can create an oversized image with a diagonal line from one corner to the other, and then apply as a fixed background on an element with [background size](https://developer.mozilla.org/en-US/docs/CSS/background-size): 100% 100%. One quibble is the line thickness will change depending on the pixel size of the viewport, but during a single session that won’t be noticeable.March 28, 2013 at 7:33 pm #130091gabyMember
You can use a diagonal (`to bottom right`) gradient that is very thin..
background:linear-gradient(to bottom right,
}March 6, 2017 at 9:27 am #252449allicarnParticipant
Expanding on gaby’s post, you can use calc to get the precise pixel width that you want that line to be:
$line-color: red; $line-width: 1px; background-image: linear-gradient(to bottom left, transparent 50%, $line-color 50%, $line-color calc(50% + $line-width), transparent calc(50% + $line-width));
See a working codepen example here.
- The forum ‘Other’ is closed to new topics and replies.