Nested classes selectors

后端 未结 6 1034
你的背包
你的背包 2021-02-19 14:06

If I have something like this in my HTML

    
Welcome on my web
相关标签:
6条回答
  • 2021-02-19 14:21

    You can use

    
    span.welcome
    #top .welcome
    #top div.txt span.welcome
    .welcome
    
    0 讨论(0)
  • 2021-02-19 14:22

    If you want to use that 'welcome' class for perticular span tag than you can use two ways like...

    .txt span.welcome

    or

    span.welcome

    it will works for your CSS class in your code perfectly.

    this is the concept of nesting class you can directly refer from internet sources too.

    0 讨论(0)
  • 2021-02-19 14:24
    .welcome
    
    #top div.txt .welcome
    
    div#top div.txt span.welcome
    

    it depends on how specific you want to be

    0 讨论(0)
  • 2021-02-19 14:29
    div#top div.txt span.welcome
    

    or

    #top div.txt .welcome
    

    or some other variation thereof...

    0 讨论(0)
  • 2021-02-19 14:32
    #top .txt .welcome{}
    
    0 讨论(0)
  • 2021-02-19 14:36

    #top .txt is not #top.txt the latter means that the matched element has the id AND the class, while the former means that the matched element has the class, and one of its ancestors element has the id

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