4 ms·
CSS has one main problem w.r.t. layout: it does not have a universal way of specifying whether the size of an element should be determined by its contents or it
by lisper 12y ago
CSS has one main problem w.r.t. layout: it does not have a universal way of specifying whether the size of an element should be determined by its contents or its container. So you can say, for example, "Make this element take up the remaining horizontal space" (that's the default for display:block) or "Make this element just wide enough and just tall enough to contain its contents" (the default for display:inline) but it is not possible to say, "Make this element tall enough to consume the remaining vertical space." The result is that some simple layouts (e.g. a fluid layout with same-height columns underneath a header with dynamic content) are not possible in CSS. All this could be solved by simply allowing the user to specify width and height of an element in terms of either the element's contents or the element's container (or, of course, as a fixed size).
- jules 12y agoBetter yet, the size and position of an element should always be determined by the parent, but the parent may query the child for information that the parent can use to determine the sizes and positions.
- vertex-four 12y ago> it is not possible to say, "Make this element tall enough to consume the remaining vertical space." As of just a few months ago, it is. Look into the now-almost-standardised (last call working draft) version of flexbox, which is implemented in recent versions of Firefox and Chrome, and also IE11. An example of what you say is impossible, in just a few lines of CSS: http://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ http://philipwalton.github.io/solved-by-flexbox/demos/sticky...
- lisper 12y agoIt looks like you edited your comment. The original link was: http://philipwalton.github.io/solved-by-flexbox/demos/holy-grail/ http://philipwalton.github.io/solved-by-flexbox/demos/holy-g... and now it is: http://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ http://philipwalton.github.io/solved-by-flexbox/demos/sticky... The latter is not what I described, and I can't get the former to work even in the latest Firefox.
- vertex-four 12y agoOops. I read what you said and thought the current one matched what I quoted better - sorry. I'm using Firefox 32.0.3, and both examples work for me perfectly. I'm not sure what the issue is.
- pessimizer 12y agoBoth work for me fine, too. Latest Firefox on Debian. According to: http://css-tricks.com/snippets/css/a-guide-to-flexbox/ http://css-tricks.com/snippets/css/a-guide-to-flexbox/ Firefox should work from v22 on.
- nojvek 12y agoflexbox support for mobile browsers is still pretty terrible.