css - 无法在 Scss 中设置占位符文本的样式

标签 css html sass

我是 SCSS 的新手。我正在尝试将我的占位符文本设置为从浅灰色到深灰色。 附上html代码:

 <div class="form-group">
     <textarea class="thread-textarea" ng-maxlength="255" maxlength="255" ng-model="newMessage.Content" ng-keyup="keycount($event)"placeholder="If this is an emergency, call 911. Otherwise, type your message here. We try to respond within 24 hours."title="Type your message" spellcheck="true" aria-labelledby="typeYourMessage"></textarea>
     <span class="aria-hidden" id="typeYourMessage">Type your message</span>
 </div>

附上我的相关scss代码

 $darkgrey: #333333;
 textarea{
     @include placeholder
     {
       color: $darkgrey;
     }
 }

我想将占位符的颜色从灰色更改为深灰色。任何帮助将不胜感激。

最佳答案

/* cross browser way */

textarea::-webkit-input-placeholder { /* Chrome/Opera/Safari */
  color: pink;
}
textarea::-moz-placeholder { /* Firefox 19+ */
  color: pink;
}
textarea:-ms-input-placeholder { /* IE 10+ */
  color: pink;
}
textarea:-moz-placeholder { /* Firefox 18- */
  color: pink;
}

/* sass whould be like this */
/*
$darkgrey: #333333;
textarea{
  &::-webkit-input-placeholder {
    color: $darkgrey;
  }
  &::-moz-placeholder {
    color: $darkgrey;
  }
  &:-ms-input-placeholder {
    color: $darkgrey;
  }
  &:-moz-placeholder {
    color: $darkgrey;
  }
}
*/
<div class="form-group">
  <textarea class="thread-textarea" ng-maxlength="255" maxlength="255" ng-model="newMessage.Content" ng-keyup="keycount($event)" placeholder="If this is an emergency, call 911. Otherwise, type your message here. We try to respond within 24 hours." title="Type your message"
  spellcheck="true" aria-labelledby="typeYourMessage"></textarea>
  <span class="aria-hidden" id="typeYourMessage">Type your message</span>
</div>

就拿这个并应用你的 sass 样式吧。

关于css - 无法在 Scss 中设置占位符文本的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39965085/

相关文章:

javascript - SQLite 和 JayData

css - 在 ionic 3 中更改后退按钮箭头颜色

css - 如何在网站宽度之外设置带有图像的div,不显示滚动条?

css - 居中内联 block - Chrome 在窗口调整大小后忽略 css 顶部位置,BUG?

javascript - 不同的组成元素

javascript - img 不显示

html - css - 我无法移动导航菜单

css - 将 : how to concat a . CSS 文件添加到我编译的 .SCSS 文件中?

css - 使用 SASS 父级选择器的更好方法

css - 当 style.css 中的 bookdown 字体发生变化时,Serif 不起作用