Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First-child selector in CSS .less file

Tags:

css

less

I have a list of links in a footer and want add a left border to each one of them apart from the first, I'm trying the following but it removes all the left borders:

ul.footerLinks {
margin:0 auto;
li{
    display: inline-block;
    zoom:1;
    *display:inline;
    color:#eee;
    padding:4px 14px;
    border-top:1px solid rgba(0,0,0,0);
    border-left:1px solid #fff;
    &:hover {
        color:#fff;
        border-top:1px solid #fff;
    }
    &:first-child {
        border-left:none;
    }
}

}

I also tried adding the border to the right and using :last-child but same result, all borders disappeared.

Anything obviously wrong?

like image 970
StudioTime Avatar asked Dec 19 '25 23:12

StudioTime


1 Answers

You can try something like below . Even i am new, just trying to help.

li{
        display: inline-block;
        zoom:1;
        *display:inline;
        color:#eee;
        padding:4px 14px;
        border-top:1px solid rgba(0,0,0,0);

        &:hover {
            color:#fff;
            border-top:1px solid #fff;
        }
       &:not(:first-child) {
        border-left:1px solid #fff;
    }
    }

Or Simply

    li{
            display: inline-block;
            zoom:1;
            *display:inline;
            color:#eee;
            padding:4px 14px;
            border-top:1px solid rgba(0,0,0,0);

            &:hover {
                color:#fff;
                border-top:1px solid #fff;
            }

        }

li:not(:first-child) {
     border-left:1px solid #fff;
}
like image 80
Richa Avatar answered Dec 24 '25 12:12

Richa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!