Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other diagonal line

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #34062
    dynamyc
    Member

    I’m wondering how to draw a diagonal line between opposite corners of the browser window?
    Or it’s more simple to make a diagonal line in photoshop and then put it as a background, but the problem if the diagonal line will look perfect in every screen size and browser…

    #85611
    chrisburton
    Participant

    Soo..you want a diagonal line on the upper left and another on the bottom right?

    #85679
    dynamyc
    Member

    No, a diagonal line from upper left to bottom right.

    #85712

    What about something like this with a CSS gradient? You could tighten up the black so that it’s very thin and there isn’t much of a fade between the two yellow sections in the example below.

    background-image: -webkit-gradient(
    linear,
    left bottom,
    right top,
    color-stop(0.07, #FFFF00),
    color-stop(0.5, #000000),
    color-stop(1, #FFFF00)
    );
    background-image: -moz-linear-gradient(
    left bottom,
    #FFFF00 7%,
    #000000 50%,
    #FFFF00 100%
    );
    #85717
    chrisburton
    Participant

    @tristanzimmerman – you have the right idea with using gradients, however, he wants a diagonal line.


    @dynamyc
    http://jsfiddle.net/e9eUU/ and http://jsfiddle.net/x3sme/

    You can also use an image for fallback if you’d like.

    #85722
    dynamyc
    Member

    Thanks for the ideas !!!

    #85729
    dynamyc
    Member

    @ChristopherBurton now I’m wondering how to make just one diagonal line to fit perfectly both left top and right bottom…

    #85730
    chrisburton
    Participant

    You mean so only 1 goes from corner to corner?

    I spoke about this on Twitter and according to Tab Atkins & Lea Verou it isn’t currently possible with CSS gradients.

    #85751
    dynamyc
    Member

    Yes, 1 goes from corner to corner, ah thanks anyway!

    #85760
    chrisburton
    Participant

    @dynamyc – It’s possible with javascript as Tab has said.

    #85785
    Mottie
    Member

    Maybe try something like this… with a minimal amount of scripting (I used jQuery here)

    HTML


    CSS

    #bkgd, #bkgd2 {
    position: absolute; /* use fixed to keep it in place */
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border: solid;
    border-color: transparent transparent black black;
    z-index:-2;
    }
    #bkgd2 {
    right: 1px;
    border-color: transparent transparent white white;
    z-index:-1;
    }

    jQuery

    var w = $(window),
    b = $('#bkgd, #bkgd2');

    var fixbkgd = function(){
    var x = w.width() + 'px ',
    y = w.height() + 'px ';
    b.css({
    'border-width' : y + x
    });
    }

    w.resize(fixbkgd);
    fixbkgd();
    #85812
    seb_z_lite
    Member

    what about a css transform:rotate? with an old-school


    tag? man, If Nicolas Gallagher can do a whole set of icons only with css, this has to be possible with Css!

    #85813
    seb_z_lite
    Member

    he said one diagonal line.

    #85814
    chrisburton
    Participant

    @Mottie – Nice!


    @seb_z_lite
    – It’s not that simple. Trust me, if anyone would know the answer, it would be those two (Lea Verou & Tab Atkins).

    #85841
    chrisburton
    Participant

    @cnwtx – It needs to hit the corners of the browser and stay that way when resizing. At this point it will only work with javascript.

Viewing 15 posts - 1 through 15 (of 22 total)
  • The forum ‘Other’ is closed to new topics and replies.