簡體   English   中英

CSS 鏈接嵌套 styles

[英]CSS link nested styles

我需要創建很多鏈接styles:

  a:link {color: one;}
  a:visited {color: two;}
  a:hover {color: three;}
  a:active {color: four;}

但對於 a.1 - a.10

有什么辦法可以將代碼切割成更緊湊的變體?

謝謝。

你不能用簡單的 CSS 做到這一點,你可以使用 SASS 來做你想做的事。

這是關於嵌套的 SASS 文檔

您將能夠創建類似的東西:

.my-class-1 a, .my-class-2 a {
  :link {
    color: one;        
  }
  :visited {
    color: two;
  } 
  [...]     
}

如果您的 class 需要多種樣式,您仍然可以像這樣嵌套您a ,它仍然更容易閱讀和更快地編寫:

 .my-class-1 a {
  :link {
    color: one;        
  }
  :visited {
    color: two;
  } 
  [...]     
}
.my-class-2 a {
  :link {
    color: three;        
  }
  :visited {
    color: four;
  } 
  [...]     
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM