Bourbon/Sass: #{$all-text-inputs} with hover or focus?

时光毁灭记忆、已成空白 提交于 2019-12-23 19:00:56

问题


According to the Bourbon docs, you can use #{$all-text-inputs} to turn this:

#{$all-text-inputs} {
  border: 1px solid green;
}

into this:

input[type="email"], input[type="number"],   input[type="password"], input[type="search"],
input[type="tel"],   input[type="text"],     input[type="url"],      input[type="color"],
input[type="date"],  input[type="datetime"], input[type="datetime-local"],
input[type="month"], input[type="time"],     input[type="week"] {
  border: 1px solid green;
}

Is there a way with Bourbon or Sass to apply :hover or :focus to each?

#{$all-text-inputs:hover} and #{$all-text-inputs}:hover did not work.


回答1:


You should be able to just nest the :hover and :focus styles using the Sass parent selector:

#{$all-text-inputs} {
  border: 1px solid green;
  &:hover, &:focus {
    // some styles
  }
}



回答2:


How about #{$all-text-inputs-hover} instead of #{$all-text-inputs:hover}?

And for the focus #{$all-text-inputs-focus}

Look the spec again http://bourbon.io/docs/#html5-input-types



来源:https://stackoverflow.com/questions/10254453/bourbon-sass-all-text-inputs-with-hover-or-focus

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!