Increase body width to fit content

I want an HTML page with a border around the content. Content does not fit the screen.

Example:

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

I would like the DIV border to be 2000 pixels wide. However, it is as wide as the browser window.

How to make the external DIV as wide as possible than its contents, preferably without Javascript?

+4
source share
2 answers

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

+10
source

Just go for a swim.

  <div style="border: solid red 1px; float: left;"> <div style="width: 2000px;"> Hello world </div> </div> 
+2
source

Source: https://habr.com/ru/post/1345086/


All Articles