Can I make the CSS :after pseudo element append content outside the element?

前端 未结 3 1110
失恋的感觉
失恋的感觉 2021-01-01 08:51

I want to format a breadcrumb trail of links using an HTML » entity between adjacent links, so it looks like this:

home »

3条回答
  •  借酒劲吻你
    2021-01-01 09:25

    Normally you code these menus as ordered lists anyway, so it makes sense to do something like this instead:

    #breadcrumb-trail ol { 
        list-style: none; 
        margin: 0;
        padding: 0; 
    }
    
    #breadcrumb-trail li { 
        display: inline; 
    }
    
    #breadcrumb-trail li:after { 
        content: ' » '; 
    }
    
    #breadcrumb-trail li:last-child:after { 
        content: none; 
    }

提交回复
热议问题