I used below code for showing ellipsis if text length is more in a placeholder. It's working good in Chrome and Firefox. Where as in IE it's not working.
input[placeholder] {
text-overflow:ellipsis;
}
I was having the same problem and came across this blog post from Front End Tricks And Magic that worked for me. The gist of the blog is that you CAN do an ellipsis in an input in IE, however only if the input has a readonly attribute.
Obviously in many scenarios we don't want our input to have a readonly attribute. In which case you can use JavaScript to toggle it. This code is take directly from the blog, so if you find this answer helpful you might consider checking out the blog and leaving a comment of appreciation to the author.
HTML:
<div class="long-value-input-container">
<input type="text"
value="sdghkjsdghhjdfgjhdjghjdfhghjhgkdfgjnfkdgnjkndfgjknk" class="long-
value-input" readonly />
</div>
CSS:
.long-value-input {
width: 200px;
height: 30px;
padding: 0 10px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
JavaScript (using jQuery)
// making the input editable
$( '.long-value-input' ).on( 'click', function() {
$( this ).prop( 'readonly', '' );
$( this ).focus();
})
// making the input readonly
$( '.long-value-input' ).on( 'blur', function() {
$( this ).prop( 'readonly', 'readonly' );
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With