Placeholder Mixin SCSS/CSS

前端 未结 6 817
挽巷
挽巷 2020-11-28 01:34

I\'m trying to create a mixin for placeholders in sass.

This is the mixin I\'ve created.

@mixin placeholder ($css) {
  ::-webkit-input-placeholder {         


        
6条回答
  •  长情又很酷
    2020-11-28 02:25

    Why not something like this?

    It uses a combination of lists, iteration, and interpolation.

    @mixin placeholder ($rules) {
    
      @each $rule in $rules {
        ::-webkit-input-placeholder,
        :-moz-placeholder,
        ::-moz-placeholder,
        :-ms-input-placeholder {
          #{nth($rule, 1)}: #{nth($rule, 2)};
        }  
      }
    }
    
    $rules: (('border', '1px solid red'),
             ('color', 'green'));
    
    @include placeholder( $rules );
    

提交回复
热议问题