Reputation: 13
I need to add a second text (required) in input text, diferent style/position of placeholder. But when user clicks, it should disappear, like placeholder. It's possible?
<style>
.inputDataText{
padding:13px;
border-width:1px;
border-radius:9px;
border-style:solid;
border-color:#d9d9d9;
width:100%;
}
</style>
<input id="demoTextBox" type="text" value="" class="inputDataText" placeholder="NAME">
Put an example image here:
Upvotes: 0
Views: 3458
Reputation: 5422
This could be done with the :empty
pseudo selector
.inputDataText:empty::after {
// show something
}
.inputDataText::after {
// hide something
}
You will have to play with the exact CSS, but that's the gist
Upvotes: 0
Reputation: 14149
try
.inputDataText{
padding:13px;
border-width:1px;
border-radius:9px;
border-style:solid;
border-color:#d9d9d9;
width:100%;
box-sizing: border-box;
}
.inputwrapper{
position: relative;
}
.inputwrapper::after {
content: attr(data-required);
position: absolute;
right: 8px;
top: 50%;
font-size: 15px;
transform: translateY(-50%);
color: #ccc;
}
<div class="inputwrapper" data-required="(required)">
<input id="demoTextBox" type="text" value="" class="inputDataText" placeholder="NAME">
</div>
Upvotes: 2