简体   繁体   中英

css last ul styling

I would like to add different styling to my last ul element with the class name footer_list , but none of the following things are working

ul.footer_list:last-child {
    border-right: none;
}

#menu-bottom.pads ul.footer_list:last-child {
    border-right: none;
}

the structure looks as it follows

<div class="pads clearfix" id="menu-bottom">
    <ul class="footer_list">
        <li><a title="" href=""></a></li>
    </ul>

    <ul class="footer_list">
        <li><a title="Zu den Dell Gutschein Codes" href="/dell-gutschein-codes/"></a></li>
    </ul>
    <ul class="footer_list">
        <div class="menu-footer-container">
            <ul class="menu" id="menu-footer">
                <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-25" id="menu-item-25"><a href=""></a></li>
            </ul>
        </div>
    </ul>
</div>

You could also use the last-of-type pseudo selector.

.footer_list:last-of-type {
    border-right: none;
}

You're using the wrong selector. Rather than:

ul.footer_list:last-child {
    border-right: none;
}

It should be:

.footer_list:last-child {
    border-right: none;
}

For an example to see the selector working correctly: http://jsfiddle.net/kDhS8/

This works ! ( http://jsfiddle.net/NJcVE/1/ )

.footer_list:last-child { border-right: none; }

and for IE7/8 you can add a class to last ul you want. Example: CSS:

.lt-ie9 .last-child {border-right: none;}

Jquery:

/* LAST CHILD HACK FOR IE7/8 */
$(function(){
    if( $.browser.msie ){
     if( $.browser.version == 7.0 || $.browser.version == 8.0 ){
        $('.footer_list').each(function(){
            if( $(this).is(':last-child') ){
                $(this).addClass('last-child');
            }       
        });
     } 
});

When you're using last-child , it means in your ul all of the li s are children, so you have to unify your ul and the last li is your last-child , something like this:

CSS:

.footer_list li{
    border: 1px solid #000;
}
.footer_list li:last-child {
    border: none;
}

HTML:

<ul class="footer_list">
    <li>Menu 1</li>
    <li>Menu 2</li>
    <li>Menu 3</li>
</ul>

you can use This

#menu-bottom ul:last-child  {
    //css for Last ul tag
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM