【问题标题】:CSS Style extension with renaming带有重命名的 CSS 样式扩展
【发布时间】:2013-12-04 04:59:29
【问题描述】:

我的问题是关于 CSS 样式的重命名和扩展。 假设我导入了一个样式如下的css文件

// These two styles are from imported css

buttonStyle{ ....    }    
buttonStyle:hover{....}


// I want to create a new style 
   myStyle extends buttonStyle:hover { ...}

是否可以扩展我的新样式,以便我的样式与buttonStyle+buttonStyle:hover+ myStyle 内容合并

【问题讨论】:

  • 不在 CSS 中,但您可以使用 SCSS 来做到这一点。

标签: html css extend


【解决方案1】:

我们不能在 CSS 中扩展属性,你为什么不能这样做:

在导入的 CSS 中,我们只是添加了 myStyle 和其他两个

buttonStyle, myStyle {
 .... 
}

buttonStyle:hover, myStyle {
....
}

myStyle {
// Add on properties for myStyle
}

这样 myStyle 将获得前两个的属性,然后是第三个的属性,并且重复的属性将根据其优先级被覆盖。

【讨论】:

  • Bease buttonStyle 是一个外部 css,所以我不能把我的样式放在它旁边。
猜你喜欢
  • 2018-01-11
  • 2013-04-25
  • 2016-06-16
  • 2018-08-06
  • 2018-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多