【发布时间】:2018-10-09 20:32:40
【问题描述】:
我有一个专门用于货币的文本输入。在文本字段内,应该说 [$Other CAD]。“$Other”应该左对齐,“CAD”应该右对齐,我目前在“$Other”和“CAD”之间只有一堆空格.这对于不同的浏览器等并不理想。有没有一种简单的方法可以让占位符的“CAD”部分正确对齐,这样无论浏览器如何,它都始终适合?另外,我可以为占位符设置两种不同的文本颜色吗?例如,灰色的“$”和“CAD”,黑色的“Other”
<style>
.donation-amount-input {
height: 65px;
font-size: 34px;
}
.form-control::placeholder {
font-size: 34px;
}
#S {
color: #aaaaaa;
position: absolute;
font-size: 36px;
padding-left: 10px
}
#Other {
position: absolute;
font-size: 36px;
padding-left: 35px;
}
#CAD {
color: #aaaaaa;
position: absolute;
font-size: 36px;
padding-left: 40%;
}
</style>
<body>
<p onclick="fakePlaceholder()" id="S">$</p>
<p onclick="fakePlaceholder()" id="Other">Other</p>
<p onclick="fakePlaceholder()" id="CAD">CAD</p>
<input
type="text"
onselect="fakePlaceholder()"
class="form-control donation-amount-input"
id="other-amount"
/>
</body>
<script>
function fakePlaceholder() {
var S = document.querySelector('S');
S.style.display = 'none';
var Other = document.querySelector('Other');
Other.style.display = 'none';
var CAD = document.querySelector('CAD');
CAD.style.display = 'none';
}
</script>
【问题讨论】:
标签: html css formatting placeholder