Descend z-index logically

后端 未结 3 1449
一生所求
一生所求 2020-12-21 23:33
3条回答
  • 2020-12-22 00:04

    Status Update:   If CSS and JavaScript are disabled then proper fallback for breadcrumbs will occur.

    Reference:   jsFiddle

    Screenshot of CSS and JavaScript Enabled: enter image description here

    Screenshot of CSS and JavaScript Disabled:

            enter image description here


    Extra: If a CSS3 version is acceptable, I was inspired to make a version with Arrows at this SO Answer.


    EDIT:

    Extra jsFiddle with alternate style by Simon Sarris.

    0 讨论(0)
  • 2020-12-22 00:09

    You can do it like this:

    $($('#crumbs > a').get().reverse()).css('z-index', function(index) {
        return index+1;
    });
    

    Or, if you'd prefer to loop with .each():

    $($('#crumbs > a').get().reverse()).each(function(index) {
        $(this).css('z-index', index+1);
    });​​
    

    Note that for this to work, you'll need to ensure that your a elements have position: relative.

    0 讨论(0)
  • 2020-12-22 00:15

    Without positioning z-index is pretty much useless

    <div id="crumbs">
    
        <a href="#" style="position:relative;z-index: 4;">Workplace Standards</a> &#62;
        <a href="#" style="position:relative;z-index: 3;">Resources</a> &#62;
        <a href="#" style="position:relative;z-index: 2;">Guides</a> &#62;
        <a href="#" style="position:relative;z-index: 1;">Public holidays</a>
    
    </div>
    

    Example

    MDN

    0 讨论(0)
提交回复
热议问题