Ere*_*man 5 html css wordpress input placeholder
CSS中的一个输入占位符中是否可以有2种不同的字体大小?
在常规html中,你可以使用span,:before,&:after等.
但在输入中你不能做所有这些事情,所以我想了解它是否可能......
谢谢
要在同一占位符中应用不同的样式是不可能的.
然而,你可以做的是使用伪元素或表现为占位符的div,并在输入被聚焦时隐藏/显示它.
这可能有所帮助:
$("#input").keyup(function() {
if ($(this).val().length) {
$(this).next('.placeholder').hide();
} else {
$(this).next('.placeholder').show();
}
});
$(".placeholder").click(function() {
$(this).prev().focus();
});Run Code Online (Sandbox Code Playgroud)
.placeholder {
position: absolute;
margin: 7px 8px;
color: #A3A3A3;
cursor: auto;
font-size: 14px;
top: 7px;
}
.small {
font-size: 10px;
}
input {
padding: 5px;
font-size: 11pt;
position: relative;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="input" type="text" />
<div class="placeholder">Email <span class="small">address</span>
</div>Run Code Online (Sandbox Code Playgroud)