Child-wide item

I have <pre>, and I put in it some content in which it can be longer than the width of the window. I expected to <pre>take the width of my children, but it doesn't seem to be that way. <pre>applies the width of the window instead of the content inside.

Demo: http://jsfiddle.net/DerekL/d6Avv/1/

From what I know, <pre>it seems to have a width: 100%default value that causes this problem.

enter image description here

I am looking for a solution to this problem. However, it is preferable to use only CSS solutions.

+4
source share
2 answers

Not sure if this will work based on any content you have, but installation

display: inline-block;

pre pre, .


: JSFiddle

div, pre, inline-block , div display: block;.

+2

white-space: normal;

pre.

white-space: nowrap;, , .

+1

All Articles