fail to change placeholder color with Bootstrap 3

前端 未结 10 1047
暗喜
暗喜 2021-01-31 01:27

Two questions:

  1. I am trying to make the placeholder text white. But it doesn\'t work. I am using Bootstrap 3. JSFiddle demo

  2. Another question is h

10条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-31 01:59

    Bootstrap has 3 lines of CSS, within your bootstrap.css generated file that control the placeholder text color:

    .form-control::-moz-placeholder {
      color: #999999;
      opacity: 1;
    }
    .form-control:-ms-input-placeholder {
      color: #999999;
    }
    .form-control::-webkit-input-placeholder {
      color: #999999;
    }
    

    Now if you add this to your own CSS file it won't override bootstrap's because it is less specific. So assmuning your form inside a then add that to your CSS:

    form .form-control::-moz-placeholder {
      color: #fff;
      opacity: 1;
    }
    form .form-control:-ms-input-placeholder {
      color: #fff;
    }
    form .form-control::-webkit-input-placeholder {
      color: #fff;
    }
    

    Voila that will override bootstrap's CSS.

提交回复
热议问题