微信小程序placeholder設置自定義顏色


原地址鏈接:https://blog.csdn.net/august_leo/article/details/80877382

這是微信小程序input組件的官方文檔描述,下圖紅框里的placeholder-styleplaceholder-class就是微信小程序里用來給placeholder設置樣式的屬性。 

一、使用placeholder-style設置樣式

placeholder-style相當於在標簽的style屬性,可直接在標簽內設置。

<input type="text" placeholder="請輸入" placeholder-style="color:#e2e2e2;"></input>

示例如下:

wxml代碼:

<input type="text" placeholder="請輸入" placeholder-style="color:#000;"></input>

wxss代碼:

input{
  width: 300rpx;
  border: 2rpx solid #000;
  margin: 50rpx auto;
  border-radius:10rpx; 
}

二、使用placeholder-class設置樣式

用法:

wxml代碼:

<input type="text" placeholder="請輸入" placeholder-class="placeholderStyle"></input>

wxss代碼:

.placeholderStyle{
  //樣式
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM