代码之家  ›  专栏  ›  技术社区  ›  webmaster pf

从样式设置中排除子项:not

  •  0
  • webmaster pf  · 技术社区  · 7 年前

    我尝试使用以下HTML标记为内容的一部分应用样式:

    <li class="views-row views-row-9 views-row-odd tid-106
    ">  
    <span><a href="/fiche/bac-pro-csr">BAC Pro Commercialisation et services en restauration - CSR</a>
    <br><span class="complement">
     Bac Pro CSR avec Restaurant d'application (Section Européenne)
      </span><br> 
    Section Européenne 
    </span>
      </li>
    

    我只想要一个样式为“Section Européenne”的文本,并从span中排除内容。补充,所以我尝试在sass中不起作用的方法:

     li{
                      &:not(img):not(a):not(.complement){
                            font-weight: bold;
                            /*-webkit-text-stroke:em(1px) $gris-anthracite;//Contour de texte*/
                        }
                        &:matches(.complement){
                            font-weight: initial;
                        }}
    

    有可能做到这一点吗? 是否可以通过:not排除span via的span子级?

    像这样的?

                  &:not(img):not(a):not(>span.complement){}
    

    谢谢

    1 回复  |  直到 7 年前
        1
  •  1
  •   Temani Afif    7 年前

    您需要这样做,因为跨度在另一个跨度内:

    li span {
      font-weight:bold;
    }
    li span.complement {
      font-weight:initial; /*we revert back the inherited style*/
    }
    <li class="views-row views-row-9 views-row-odd tid-106">
      <span><a href="/fiche/bac-pro-csr">BAC Pro Commercialisation et services en restauration - CSR</a>
    <br>
    <span class="complement">
     Bac Pro CSR avec Restaurant d'application (Section Européenne)
     </span>
     <br> Section Européenne
      </span>
    </li>