Search code examples
htmlcsszurb-foundation-5

CSS3 last-child selector - select last li with .has-dropdown but not li's within that


I am really struggling to get the last item in the dropdown to have rounded edges without the items within that having rounded corners too. I have tried many variations, but always end up with the same result which is that I get the last item to have rounded edges, but all the items within it have rounded edged too. Can anyone help me out? NB. id="languagebox" won't always be the last item and so I cannot style using this ID.

Many thanks.

CSS:

ul.dropdown li.has-dropdown:last-child a {
  border-radius: 0px 0px 3px 3px;
  -moz-border-radius: 0px 0px 3px 3px;
  -webkit-border-radius: 0px 0px 3px 3px;
  border: 1px solid red;
}

HTML

<a href="#"><i class="fi-web medium"></i></a>
<ul class="dropdown">
  <li class="title back js-generated">
    <h5><a href="#">Back</a></h5></li>
  <li class="has-dropdown" id="display_currency"><a>Currency</a>
    <ul class="dropdown">
      <li class="title back js-generated">
        <h5><a href="#">Back</a></h5></li>
      <li class="lang_item active">
        <a href="javascript:void(0);"><img src="//d11fdyfhxcs9cr.cloudfront.net/flags/USD_flag.gif" alt="USD"> USD</a>
      </li>
      <li class="lang_item">
        <a href="javascript:void(0);" onclick="SetStoreCurrency('ZAR')"><img src="//d11fdyfhxcs9cr.cloudfront.net/flags/ZAR_flag.gif" alt="ZAR"> ZAR</a>
      </li>
    </ul>
  </li>

  <li class="has-dropdown" id="languagebox"><a>Language</a>
    <ul class="dropdown">
      <li class="title back js-generated">
        <h5><a href="#">Back</a></h5></li>
      <li class="lang_item active">
        <a href="javascript:void(0);"><img src="//d11fdyfhxcs9cr.cloudfront.net/design_media/flags/large/usd.png" alt="Default Language Pack (us-en)" height="13" width="22"> English</a>
      </li>
      <li class="lang_item">
        <a href="javascript:void(0);" onclick="javascript:SetLanguage(285679);"><img src="//d11fdyfhxcs9cr.cloudfront.net/design_media/flags/large/fra.png" alt="French" height="13" width="22"> French</a>
      </li>
    </ul>
  </li>
</ul>

Solution

  • ul.dropdown>li:last-child{
      border-radius: 0px 0px 3px 3px;
      -moz-border-radius: 0px 0px 3px 3px;
      -webkit-border-radius: 0px 0px 3px 3px;
      border:1px solid red;
    }