Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase body width to fit content

Tags:

html

css

width

I want a HTML page with a border around the content. The content does not fit on the screen.

Example:

<div style="border: solid red 1px;">
    <div style="width: 2000px;">
        Hello world
    </div>
</div>

I would like the bordered DIV to be 2000 pixels wide. However, it is only as wide as the browser viewport.

How can I make the outer DIV as wide as its contents, preferably without Javascript?

like image 278
Sjoerd Avatar asked Dec 17 '22 16:12

Sjoerd


1 Answers

You can make the outer <div> shrink to fit its contents ("shrinkwrap") by adding float: left.

like image 79
SLaks Avatar answered Dec 19 '22 06:12

SLaks