YES
The placeholder overflow ellipsis can be achieved quite simply:
::placeholder{ text-overflow:ellipsis; }
::placeholder{ text-overflow:ellipsis; } input{width:100%;}
<input placeholder="A Long Placeholder to demonstrate"></input> <<< Resize to see overflow
The result can also be achieved using the attribute selector:
[placeholder]{ text-overflow:ellipsis; }
This will also add the side effect of manipulating the value of the input. This may or may not be desirable.
[placeholder]{ text-overflow:ellipsis; } input{width:100%;}
<input placeholder="A Long Placeholder to demonstrate"></input> <input value="A Long value to demonstrate"></input> <<< Resize to see overflow
Tested and works in Firefox and Chrome.
As usual, IE will not play the ball!
http://jsfiddle.net/uW2cU/
START VIEWS
- Need support for older browsers?
- IE doesn't play beautifully?
I created a small css hack to simulate a placeholder. Use this code to simulate your replacement inputs. It is a bit dirty, but can offer support back in IE6 .
.Ellipsis{ box-sizing:border-box; position:relative; padding:0 5px; background:#fff; color:rgba(0,0,0,0.5); width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } .Ellipsis input{ box-sizing:border-box; position:absolute; top:0; left:0; height:100%; width:100%; display:block; background:none; border:1px solid #ddd; color:#000; padding:0 5px; } .Ellipsis input:focus{ background:#fff; }
<div class="Ellipsis"> A Long Placeholder to demonstrate A Long Placeholder to demonstrate A Long Placeholder to demonstrate <input></input> </div> <<< Resize to see overflow
Support beyond this range will require javascript.
Obsidian
source share