Is it possible to target “no target” in CSS?

后端 未结 1 821
Happy的楠姐
Happy的楠姐 2021-01-06 14:47

Is there a css selector for \"no fragment identifier present\"? The opposite of :target.

The thing is, I\'m making a document where different parts of i

1条回答
  •  情书的邮戳
    2021-01-06 15:09

    With some extra markup and more verbose and specific CSS to write, to avoid javaScript. Needs to be updated each time HTML structure is updated .

    :target ~section {
      display:none;
    }
    #one:target ~.one,
    #two:target ~.two,
    #three:target ~.three  {
      display:block;
    }
    
    
    
    
    
    
    
    The first block (showing with #one)
    The second block (showing with #two)
    The third block (showing with #three)

    0 讨论(0)
提交回复
热议问题