I can’t make unsolicited cards disappear

Asked

Viewed 42 times

-1

Hello, I have a series of cards that I have already put the respective ids, but when I click on the menu option that I want it just scrolls to the card with the id, but actually I would like all the others to disappear and only the ones of the id called stay. Can you help me? :)inserir a descrição da imagem aqui

<div class="list-group menu-casos" style="float: left">
            <a href="#varejo" class="list-group-item active">Varejo</a>
            <a href="#industria" class="list-group-item">Indústria</a>
            <a href="#marketing" class="list-group-item">Marketing</a>
            <a href="#seguro" class="list-group-item">Seguro</a>
            <a href="#educacao" class="list-group-item">Educação</a>
            <a href="#saude" class="list-group-item">Saúde</a>
            <a href="#financas" class="list-group-item">Finanças</a>
            <a href="#telecom" class="list-group-item">Telecom</a>
          </div>

<div class="card2 shadow" id="varejo" style="margin-top: 50px">
            <h2>E-commerce</h2>
            <pre>Texto</pre>
            <a href="#support" class="btn btn-primary">Saiba mais</a>
          </div>
          <div class="card2 shadow" id="varejo">
            <h2>Lojas Físicas</h2>
            <pre>Texto</pre>
            <a href="#support" class="btn btn-primary">Saiba mais</a>
          </div>
          <div class="card2 shadow" id="varejo">
            <h2>Serviços de Consumo</h2>
            <pre>Texto</pre>
            <a href="#support" class="btn btn-primary">Saiba mais</a>
          </div>
  • 1

    Dude you have to put the full code there, at least in a way that simulates your problem, only with this block of code can not help you much

  • If you don’t show the javascript you’re using to change the behavior of the page it will be difficult to help you.

  • @hugocsl Pus

  • @fernandosavio am not using js, only HTML

  • I strongly suggest you take a look at the link to get an idea of what you can and cannot do with Html: https://developer.mozilla.org/en-US/docs/Web/HTML

  • If you’re not using JS you can’t expect a different behavior than HTML provides (maybe some magic with CSS, but it’s not ideal). I mean, you have nothing to change the default behavior.

Show 1 more comment

1 answer

3


Just use :target type the href must be the same as id.

Ai in CSS only the id:target {display:block}

#varejo, 
#industria, 
#marketing {
    display: none;
}
#varejo:target , 
#industria:target , 
#marketing:target {
    display: block;
}
<div class="list-group menu-casos" style="float: left">
    <a href="#varejo" class="list-group-item active">Varejo</a>
    <a href="#industria" class="list-group-item">Indústria</a>
    <a href="#marketing" class="list-group-item">Marketing</a>
</div>

<div class="card2 shadow" id="varejo" style="margin-top: 50px">
    <h2>E-commerce</h2>
    <pre>Texto</pre>
    <a href="#support" class="btn btn-primary">Saiba mais</a>
</div>
<div class="card2 shadow" id="industria">
    <h2>Lojas Físicas</h2>
    <pre>Texto</pre>
    <a href="#support" class="btn btn-primary">Saiba mais</a>
</div>
<div class="card2 shadow" id="marketing">
    <h2>Serviços de Consumo</h2>
    <pre>Texto</pre>
    <a href="#support" class="btn btn-primary">Saiba mais</a>
</div>

  • To compatibility is pretty decent, I thought it would be much worse.

  • 1

    @fernandosavio yes, it is a very old pseudo-class until, and the coolest thing is that it does not need to be father > son. you can catch qq element in qq part of the screen, type the for from the label to a checkbox that would be my tip to do this and not with :target... but as I do not know the reality of the AP project goes with :target even :D

  • 1

    Interesting +1!

  • @Leandrade thx

  • I had known the pseudo-class for a long time... Only in my head it was an unviable modernity to wear nowadays. hahahaha

  • @fernandosavio com o IE aposentado vc pode usar praticamente o que quiser, until the EDGE migrated to wibkit, the modern browser are all Evergreen

Show 1 more comment

Browser other questions tagged

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