Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Set a Fixed Width for a Div Element with Display Inline?

Tags:

html

css

asp.net

I have the below div element:

<div style="width: 40px; height: 40px; overflow: hidden; display: inline;">
                Hello my friend, How are you?</div>

The width is always ignored! how could I have it as 40px?

Thanks,

like image 227
The Light Avatar asked Nov 24 '11 21:11

The Light


1 Answers

Use display:inline-block;. Size properties are ignored at most elements with display:inline.

<div style="width: 40px; height: 40px; overflow: hidden; display: inline-block;">
            Hello my friend, How are you?</div>
like image 162
Rob W Avatar answered Sep 30 '22 19:09

Rob W