Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a span text overflow, like an input

Tags:

css

overflow

I am trying to achieve this with a span:

enter image description here

This is what I have:

<span>some text goes here</span>

span{width:50px;overflow:hidden;float:left;}

This gives me this:

enter image description here

I tried every possible way I could think of but the text keeps moving downwards. I don't want to specify the height.

like image 658
jQuerybeast Avatar asked Jan 07 '12 09:01

jQuerybeast


People also ask

Can you put an input inside a span?

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.

How do you input and span on the same line?

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.

How do I overflow text in CSS?

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.


1 Answers

Use white-space: nowrap. Otherwise the content will always expand the box vertically.

Demo

like image 174
nikc.org Avatar answered Oct 04 '22 18:10

nikc.org