【发布时间】:2018-07-25 20:34:10
【问题描述】:
我在@each 循环中遇到了输出属性选择器的问题。 CSS 输出呈现'{$type}'。我该如何正确地做到这一点?
SASS
@each $type in text, email
input[type='{$type}']
background-color: $white
border: 2px solid $loblolly
border-radius: 6px
color: $black
font-family: $gotham
font-size: $h5
height: 2.75rem
padding: 0 .625rem 0 .3125rem
text-indent: .3125rem
transition: border-color .5s ease background-color .5s ease
CSS(输出)
input[type='{$type}'] {
background-color: #fff;
border: 2px solid #c4d0d6;
border-radius: 6px;
color: #242934;
font-family: "Gotham A", "Gotham B", Helvetica, Arial, sans-serif;
font-size: 1.125rem;
height: 2.75rem;
padding: 0 0.625rem 0 0.3125rem;
text-indent: 0.3125rem;
transition: border-color 0.5s ease background-color 0.5s ease;
}
input[type='{$type}'] {
background-color: #fff;
border: 2px solid #c4d0d6;
border-radius: 6px;
color: #242934;
font-family: "Gotham A", "Gotham B", Helvetica, Arial, sans-serif;
font-size: 1.125rem;
height: 2.75rem;
padding: 0 0.625rem 0 0.3125rem;
text-indent: 0.3125rem;
transition: border-color 0.5s ease background-color 0.5s ease;
}
【问题讨论】:
-
你为什么要这样做,如果他们都共享相同的样式,为什么不给他们一个共享的类?
-
@Pete 我离开我的电脑并意识到同样的事情然后看到了这条评论。 ???好点子!