在 SASS 中如何定义属性选择器?

在 CSS,你能做到的:

input[type=submit] {
// properties
}

它对于设计表单按钮非常有用。

如何在 SASS 做同样的事情?

91035 次浏览

This converter website says:

input[type=submit]
// properties

You can also nest it like this

input
&[type="submit"]
....
&[type="search"]
....

I use the one below in my project.

.bg-brand-3 {
background-color: black;
&[type="button"]:enabled {
&:hover {
background-color: orange;
}
&:active {
background-color: green;
}
}
&[type="submit"] {
// css
}
}

The :enable has the same meaning as :not(:disabled)