[英]Is there a way with CSS to add space between the cursor, and the placeholder text in an input?
[英]add space between elements in placeholder
您可以將占位符圖標顯示為背景圖像,然后使用:placeholder-shown
的否定將其隱藏。
[type=email] { background-image: url(https://image.flaticon.com/icons/svg/131/131155.svg); background-position: calc(100% - 8px) center; background-repeat: no-repeat; background-size: 16px 16px; padding: 1em 16px 1em 1em; border: 1px solid; } [type=email]:not(:placeholder-shown) { background-image: none; }
<div class="form-group"> <input type="email" class="form-control" id="FirstName" aria-describedby="emailHelp" placeholder="FirstName"> </div>
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
word-spacing: 9px !important;
}
::-moz-placeholder { /* Firefox 19+ */
word-spacing: 9px !important;
}
:-ms-input-placeholder { /* IE 10+ */
word-spacing: 9px !important;
}
:-moz-placeholder { /* Firefox 18- */
word-spacing: 9px !important;
}
您可以將輸入和圖標放入<div>
並從輸入中刪除邊框並將其添加到<div>
<div class="" style='border:1px solid black; width: 150px'>
<input type="text" class="form-control" placeholder="Search" style="border:0px;" />

</div>
我不認為有任何方法可以在同一占位符文本中以不同方式對齊文本和圖標
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.