I am trying to achieve this with a span:
This is what I have:
<span>some text goes here</span>
span{width:50px;overflow:hidden;float:left;}
This gives me this:
I tried every possible way I could think of but the text keeps moving downwards. I don't want to specify the height.
Wrap both your input and your span inside a container, position this container as relative, and the span as absolute. You can now do whatever you like with the span.
Just set them so their width totals around 100% and float them next to each other. In your snippet, the input takes up 100% of the div, so the span has to go above it. In order for them to be able to wit on the same line, they have to have a total length of less than 100% or 700px to fit in the div.
To clip at the transition between characters you can specify text-overflow as an empty string, if that is supported in your target browsers: text-overflow: ''; . This keyword value will display an ellipsis ( '…' , U+2026 HORIZONTAL ELLIPSIS ) to represent clipped text.
Use white-space: nowrap
. Otherwise the content will always expand the box vertically.
Demo
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