2016-10-10 44 views
-1

我是SCSS的新手。我试图将我的占位符文本从浅灰色转换为深灰色。 附件是html代码:无法在Scss中设置占位符文本的样式

<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; 
    } 
} 

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

+0

您使用的是波旁威士忌吗? –

+0

这不是您选择输入占位符的方式。看到这里:http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css – Turnip

+0

@Turnip与波旁威士忌它会这样工作:http://bourbon.io/docs /#placeholder我的猜测是波旁没有正确设置。 –

回答

1

/* 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的风格吧。

+0

不工作..... –

+0

你复制了注释掉的CSS并使用它吗? – orangeh0g

+0

是的,但仍然没有任何区别。 :( –

相关问题