Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
67
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

@yassh

placeholderの色を変える方法

  • placeholderの色を変えるには、::placeholder疑似要素を使う。
  • IEをサポートするなら、:-ms-input-placeholder疑似クラスも使う。
  • Edgeをサポートするなら、::-ms-input-placeholder疑似要素も使う。
input::placeholder {
  color: red;
}

/* IE */
input:-ms-input-placeholder {
  color: red;
}

/* Edge */
input::-ms-input-placeholder {
  color: red;
}

次のようにSCSSでmixin化してもよいだろう。

@mixin placeholder($color) {
  &::placeholder {
    color: $color;
  }

  // IE
  &:-ms-input-placeholder {
    color: $color;
  }

  // Edge
  &::-ms-input-placeholder {
    color: $color;
  }
}

input {
  @include placeholder(red);
}

デモ

参考文献

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
67
Help us understand the problem. What are the problem?