简体   繁体   English

具有重命名功能的CSS样式扩展

[英]CSS Style extension with renaming

My question is about renaming and extending of css styles. 我的问题是关于重命名和扩展CSS样式。 Lets say I imported a css file which has a style below 可以说我导入了一个css文件,其样式如下

// These two styles are from imported css

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


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

Is it possible to extend my new style so that my style will be merged with buttonStyle+buttonStyle:hover+ myStyle content 是否可以扩展我的新样式,以便将我的样式与buttonStyle+buttonStyle:hover+ myStyle内容合并

We cant extend properties in CSS, Why cant you do like this: 我们无法在CSS中扩展属性,为什么您不能这样做:

Here in the imported CSS we are just adding myStyle along with the other two 在导入的CSS中,我们只是将myStyle与其他两个添加在一起

buttonStyle, myStyle {
 .... 
}

buttonStyle:hover, myStyle {
....
}

myStyle {
// Add on properties for myStyle
}

So that myStyle will get the properties of first two and then the third one and the duplicated properties will be overrided with respect to its priority. 这样myStyle将获得前两个属性,然后是第三个属性,并且重复的属性将被优先考虑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM