0

I know this question may be a bit strange, but I just don't know and can't find any information (soo maybe problem doesn't exist) and I build page where div width is dependent on the user. Is there some div width limit? Can div be for example:

width:1000000px?

Wordica
  • 2,427
  • 3
  • 31
  • 51
  • I would like to imagine it goes as big as the users limit...but I'm not 100. – 13ruce1337 Jul 14 '14 at 23:51
  • 1
    See this previous post: [**how wide can you make a webpage**](http://stackoverflow.com/questions/16643749/how-wide-and-long-can-you-make-a-web-page-is-there-a-limit) – JRulle Jul 15 '14 at 00:03

3 Answers3

1

In both Chrome and Firefox there appears to be a limit due to the way the browsers process width and height through css. I found this post about it, after using the inspect element in both Chrome and Firefox' debugging tools.

Contrary to the post, I found maximum values of 17895698 for Firefox, and 33554428 for Chrome.

Here are also a couple "bug" reports on Bugzilla about people running into the same issue: Report 1 Report 2.

As they say in one (for Gecko/Firefox engines),

CSS lengths in Gecko are limited to at most (1<<30)-1 app units, with 1<<30 treated as an infinite value. App units are 1/60 of a CSS pixel. Lengths larger than that effectively overflow the integer datatype used to store lengths.

((1<<30)-1)/60 == 17895697

which is the maximum CSS length, in CSS px, that we support, effectively.

Community
  • 1
  • 1
Chris Heath
  • 432
  • 1
  • 11
  • 22
  • Thanks, so there is some limit However, even at much lower values we ​​have a problem with performance – Wordica Jul 15 '14 at 00:31
  • I can't think of any _practical_ application to a 1.8 million pixel wide div. What are you building which requires such a large space? – Chris Heath Jul 15 '14 at 00:32
0

There's no limit per se, but once you start using large sizes SOME browsers have been known to render very slowly. You will want to test that if you use this approach. Also, you're likely to see some browser problems with really high numbers. You might want to stick with numbers between 10-20k.

Rich Remer
  • 2,123
  • 1
  • 21
  • 22
0

Based on this SO question, it would seem to be that the only constraint is the available memory of your computer. So, a div which with a width:1000000px would be possible, as would almost any other width.

At large enough width's one could foresee the browser becoming increasingly slow.

Thankfully, this is not a typical concern of most web sites...

JSFiddle here. Enjoy scrolling.

Community
  • 1
  • 1
Friendly King
  • 2,396
  • 1
  • 23
  • 40
  • ok soo there is no limit but performance can be a problem with to big div. I don't check it but how facebook make this, when we scroll down and look at peoples share, div increased length – Wordica Jul 15 '14 at 00:07
  • ends in the middle, does this means anything? :) – Wordica Jul 15 '14 at 00:08
  • 1
    They dynamically load more content as you scroll with AJAX, and they keep adding, for sake of simplicity, divs on top of more divs. From experience on some websites with this "infinite scroll", at a certain point, my browser will become slower -- but not because the "height" of the div. Other factors are typically at play. – Friendly King Jul 15 '14 at 00:12
  • ok I also load more content when scroll move in width - I'm thinking about dynamicaly remove non visible content and add it when should be visible - butI do not know if it's not much "fun" for start, if the performance has to fall slightly. When page will be popular ( i hope soo) I will think about this. Right now I think that 20-30K in widht will be max for some time – Wordica Jul 15 '14 at 00:18