Delete a css selector

Asked

Viewed 446 times

-2

I have the following:

        <div>
            <ul class="menu-top-header-main-right">
                <li><span class="icon-procurar"></span></li>
                <li>Entrar</li>
                <li>Inscrever-se</li>
            </ul>
        </div>

and my css:

.top-header-main header div ul li span{
    display: inline-block;
    padding: 0 .8em;
    width: 20px;
    height:24px;
    vertical-align: middle;
}

.top-header-main header div ul li:not(.icon-procurar):hover{
    border-bottom: 3px solid #2BDE73;
    cursor: pointer;
}

I intend to exclude the span of :hover but it doesn’t seem to work.

Any help? Thank you.

  • 1

    Better define what would be "delete Hover span".

  • When you say delete, you don’t mean for example that you want to assign the 'display:None;' property to the element, thus making it "disappear" from the screen.

  • As you can see in the code, span is inside li, so by applying :Hover, span also takes the attributes that are defined in :Hover, but I wish span wasn’t just an image

1 answer

-2

PARENT SELECTOR

What you’re trying to do is called Parent selector which is a type of selector that NAY exists in CSS, nor in CSS3. Explaining a little better, you want to style an element according to the presence/absence of a child element. As already said cannot be achieved with CSS3, but can with jQuery:

$('li:has(span)').css("borderBottom", "none");
div ul li span{
    display: inline-block;
    padding: 0 .8em;
    width: 20px;
    height:24px;
    vertical-align: middle;
}

div ul li:hover{
    border-bottom: 3px solid #2BDE73;
    cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
  <ul class="menu-top-header-main-right">
    <li><span class="icon-procurar"></span></li>
    <li>Entrar</li>
    <li>Inscrever-se</li>
  </ul>
</div>

Some sources of conultation (in English):

CSS selector for "foo that contains bar"?

Is there a CSS Parent selector?

  • You’re saying :not exists in css3?

  • @Celibacy or :not exists in CSS 3 maybe he tried to explain something else.

  • I think so... because I know :not exists, I’ve done it before but in the way I’m trying to do it now, it doesn’t work!

  • @Céliogarcia :not is a PSEUDO class and not PARENT SELECTOR

Browser other questions tagged

You are not signed in. Login or sign up in order to post.