大便有血是什么原因男性| 什么王| 炒米泡水喝有什么功效| 1.15是什么星座| 石楠花什么味道| 雾是什么| acd是什么意思| 热伤风感冒吃什么药好| 梦见小猫崽是什么意思| 殊荣是什么意思| 提高免疫力吃什么好| 无味是什么意思| 般若是什么意思| 剁椒能做什么菜| 天空为什么会下雨| 粗粮是什么| 82年属什么的| 吃榴莲不能吃什么东西| pro是什么的缩写| 脸上爱出油是什么原因| 脸上起疙瘩是什么原因| 晚上11点多是什么时辰| 今天吃什么| 血压高吃什么| 国民老公是什么意思| 鹌鹑蛋不能和什么一起吃| 长生殿讲的是什么故事| 晚上咳嗽是什么原因| 出汗少是什么原因| 眼睛疼是什么原因| 鲫鱼吃什么| 桃代表什么生肖| 主动脉夹层什么意思| 窈窕淑女君子好逑是什么意思| 梦见打篮球是什么意思| 万中无一什么意思| 荡气回肠是什么意思| 什么是糖类抗原| 回眸一笑百媚生什么意思| 诺如病毒吃什么药| 野生黄芪长什么样子的图片| 芙蓉花又叫什么花| 太容易出汗是什么原因| 钼靶是什么意思| 肌腱炎有什么症状| 神奇是什么意思| 尿白细胞阳性是什么意思| 什么蛋不能吃脑筋急转弯| 天才是指什么生肖| 八珍胶囊适合什么人吃| 下边瘙痒是什么原因| bang是什么意思| 类风湿不能吃什么| 58岁属什么生肖| 微白蛋白高是什么情况| 阿迪达斯是什么牌子| 淋巴细胞比率低是什么意思| 莯字五行属什么| 尿痛流脓吃什么药| 脂肪由什么组成| 阴虱用什么药| 葡萄是什么季节的水果| 南浦大桥什么时候建成| 眼睛不能见光是什么病| 赵字五行属什么| 骨穿是检查什么病| 漪什么意思| 应无所住而生其心什么意思| 儿童肥胖挂什么科| 胃充盈欠佳是什么意思| 36计的第一计是什么| 卓诗尼牌子是什么档次| 牙痛上火吃什么药| 男人性功能不行是什么原因| 乳头很痒是什么原因| 有何特长一般填什么好| 彤五行属什么| 头发多剪什么发型好看| 肠上皮化生是什么意思| 骨质增生是什么意思| 乐的五行属性是什么| 退烧吃什么药好| 心路历程是什么意思| 延年是什么意思| 6月2日什么星座| tbc是什么意思| 儿童发烧挂什么科| 胸痒痒是什么原因| 一月十一是什么星座| 透明的剑是什么剑| 感冒挂号挂什么科| 燕窝是什么做的| 姜汁可乐有什么功效与作用| 马凡氏综合症是什么病| 男人都喜欢什么样的女人| 早上7点到9点是什么时辰| pc什么意思| 黄瓜是绿色的为什么叫黄瓜| 原味是什么意思| 家政公司是做什么的| 乙肝小三阳是什么| 宝宝头爱出汗是什么原因| ige是什么| 女人吃鹿鞭有什么好处| 意志是什么意思| 驿马星是什么意思| 微信什么时候推出的| 男人容易出汗是什么原因造成的| 中耳炎吃什么药效果比较好| 肝功七项查的是什么| 空心菜是什么菜| dm是什么意思| 灵芝对身体有什么好处| 神经递质是什么意思| 五行缺土是什么意思| s925是什么金| 眼睛模糊用什么眼药水| 为什么有的人皮肤黑| 口蜜腹剑是什么意思| 意味深长的意思是什么| 低血压吃什么可以补| 十一月份出生的是什么星座| 蜜糖冲水喝有什么功效| 肚子疼吃什么药管用| 什么是标准预防| 什么水果是发物| 为什么会胀气| 缺维生素b有什么症状| 羊奶有什么作用与功效| 馊主意是什么意思| 离婚的女人叫什么| 山楂干泡水喝有什么功效| 99年属兔的是什么命| 考试前吃什么提神醒脑| amh是什么检查项目| 79年属羊的是什么命| 鲛人是什么意思| 喝什么助眠| 让是什么词| uu是什么意思| 短效避孕药什么牌子好| 拔牙后喝酒有什么危害| 白术有什么作用| cue什么意思| 籽骨出现意味着什么| 牙周炎用什么药最见效| 吃什么增加抵抗力| 霏是什么意思| 花椒吃多了对身体有什么影响| 不宁腿综合症是什么原因引起的| emba是什么| 脚冰冰凉是什么原因| 保妇康栓是治疗什么的| 八仙过海开过什么生肖| 送老爸什么礼物| 广州有什么小吃特产| 贫血会出现什么症状| 梦见吃雪糕是什么意思| 太监是什么| 奇亚籽是什么| 多吃苹果有什么好处| 查染色体挂什么科| 王羲之的儿子叫什么名字| 有什么有什么四字词语| 大材小用是什么生肖| 烹调是什么意思| 生吃紫苏叶有什么功效| 专科学什么专业好就业| 白交念什么| 小妹是什么意思| 智齿旁边的牙齿叫什么| 苹果什么时候吃最好| pdr是什么意思| 孩子积食发烧吃什么药| 二月初四是什么星座| 舍我其谁是什么意思| 宾馆和酒店有什么区别| 小孩耳鸣是什么原因引起的| 跖疣长什么样| 南京有什么好玩的地方| 水压低用什么花洒| 孙楠留什么给你| 前置胎盘需要注意什么| 左手发麻什么原因| 911是什么电话| 孔雀女是什么意思| 俄罗斯信奉的是什么教| 特务是什么| 398是什么意思| 细菌性阴道炎用什么药效果最好| 梭织是什么意思| 徐州菜属于什么菜系| lee是什么意思| 肺癌不能吃什么水果| 一直不射精是什么原因| 二级医院什么意思| 膝关节积液吃什么药| 什么叫口腔溃疡| 小叶苦丁茶有什么作用和功效| 一步两步三步四步望着天是什么歌| 神经元特异性烯醇化酶是什么意思| 可乐鸡翅需要什么材料| 下压高是什么原因引起的| 备孕前需要做什么检查| 榆钱是什么| 什么是冷战| 尿液细菌高是什么原因| 很man是什么意思| 挫伤用什么药| 新生儿干呕是什么原因| 猫最喜欢吃什么| 腹部b超能检查出什么| 一边脸大一边脸小是什么原因| 什么木质手串最好| 中央政法委书记什么级别| 晒后修复用什么比较好| 小基数是什么意思| 鲜字五行属什么| 什么家庭不宜挂八骏图| 人参归脾丸和归脾丸有什么区别| 春什么秋什么的成语| 7.1什么星座| 窦性心律t波改变是什么意思| 白醋泡脚有什么好处| 咳嗽吐血是什么原因| 农历七月初七是什么节日| 宫颈转化区三型是什么意思| 调味茶和茶有什么区别| 俎是什么意思| 桃花像什么| cdts什么意思| 过期牛奶可以做什么| 尿酸高吃什么好| 谨字五行属什么| 为什么会长丝状疣| 肌桥是什么意思| 为什么作什么的成语| 什么食物含叶酸| m倾向是什么意思| 咳嗽有绿痰是什么原因| 为什么气血不足| 什么时候天黑| rad是什么单位| 纳米是什么意思| 西米是什么字| 什么是川崎病| 什么东西倒立后会增加一半| 合加羽念什么| 摩羯座后面是什么星座| 脚气是什么菌| 高铁与动车有什么区别| 小山羊是什么病| 大将军衔相当于什么官| 梦女是什么| 湿热便秘吃什么中成药| 宝宝照蓝光有什么副作用| 什么牌子的钙片好| 脖子长小肉粒是什么原因| 手指经常抽筋是什么原因| cop是什么| 短裤搭配什么鞋子| 124什么意思| 织锦缎是什么面料| 臭氧是什么味道| 百度

Why Flexboxes Aren't Good for Page Layout

Last updated:

The layout

Let's say I have a moderately complex site that I want to create on the web. My mockups are all ready, and I've identified the skeleton of the site:

This diagram is drawn from an actual site that I am looking at to make sure my requirements are sane when I start hacking on the layout specs. Each labelled section is a distinct part of the page.

The Flexbox Approach

If I was designing this layout with flexbox, I'd end up with a page structure looking like this:

("vbox" and "hbox" are container elements with display:box and an appropriate box-align value.)

<vbox>
	<hbox>
		<a/>
		<vbox>
			<b/>
			<c/>
		</vbox>
	</hbox>
	<hbox>
		<d/>
		<vbox>
			<hbox>
				<@/>
				<e/>
			</hbox>
			<f/>
		</vbox>
	</hbox>
</vbox>

Personally, I think this is relatively horrifying all by itself. The page layout is relatively complex, but this super-nested design is just... just... ugly. And while I might be able to use existing elements in my page for some of those vboxes and hboxes, I'll still have a ton of container elements that serve no purpose beyond making the layout work. <div>itis!

Here's where it gets worse, though. Say I change the layout slightly. Rather than the D block extending to the bottom of the screen, I go with a more traditional 3-column layout in the center, and just let the footer fill the entire bottom. In terms of visual change, all that happens is the lower-left corner of the layout now belongs to F rather than D. What happens?

CHAOS!

Suddenly, I have a relatively drastic rearranging of my markup:

<vbox>
	<hbox>
		<a/>
		<vbox>
			<b/>
			<c/>
		</vbox>
	</hbox>
	<hbox>
		<d/>
		<@/>
		<e/>
	</hbox>
	<f/>
</vbox>

While this layout is simpler than the prior one, it's still a bit overly complex and will require meaningless container elements to make the layout work. More importantly, though, it's significantly different from the previous layout, even though almost nothing changed!

(To be fair, it could be a relatively small change, if I'm willing to retain the now-useless vbox and hbox wrapping the @ and E blocks. But it's pretty obvious that the structure above is precisely what you'd produce if you were coding this from scratch, and so if you happened to make the change in the opposite direction the large change would be required.)

Flexbox seems fundamentally vulnerable to this. It can only deal with one-dimensional flows of elements, so certain types of layout changes that break from those simple notions can create a cascade of changes as you suddenly need to nest multiple flexboxes that are only positioning two or three elements.

The Template Approach

With Template Layout you're saved from this. To start with, here's the extra structure you need:

(this space intentionally left almost blank)

This is because the layout is expressed in pure CSS, not in the page structure. Here's the CSS for the original layout:

body {
	display: "abb"
	         "acc"
	         "d@e"
	         "dff";
}

#logo { position: a; }
#header { position: b; }
(etc.)

Notice the eery similarities between the display property and the original file...

Now, here's what the CSS looks like if we make the change in how blocks D and F sit:

body {
	display: "abb"
	         "acc"
	         "d@e"
	         "fff";
}

#logo { position: a; }
#header { position: b; }
(etc.)

(In case you missed it, a single character changed.)

Conclusion

Flexboxes are great for a lot of things, and I think I'm going to be powering them up a little to make them even better, but they are not the correct solution for page layout. Template Layout is.

(a limited set of Markdown is supported)

Thank you for your article.

Can you please explain in more detail the "Template Approach"? Can these CSS boxes handle complex dynamic content? Browser support? Appropriate for "responsive" designs?

Also, would CSS Templates be appropriate for developing a complex nested layout in XUL? Or is Flexbox the way to go? Would there be an appropriate mix?

Thanks for your time.

Reply?

(a limited set of Markdown is supported)

For more detail, you'll want to read the Grid Layout spec.

Yes, they can handle complex content. No browser supports them yet, but there are several implementations in progress. They are absolutely appropriate for responsive designs, and in fact will make responsiveness unbelievably simpler to deal with.

Grid Layout will be great for arbitrary websites and applications, so it should be fine for XUL too. You can nest grids inside of grids, for example, so you can have different components defining their layout with grids, then the overall page placing the components themselves in the page grid.

As I explain in the post, Flexbox is great for 1d layout, when your boxes should be laid out in a line. Grid is for 2d layouts. These should absolutely be mixed - pages will almost always want to use Grid, but a lot of the time individual components will want Flexbox, which is more powerful within the simpler area that it covers.

Reply?

(a limited set of Markdown is supported)

I’d like to point out that the first section of the article appears to have a formatting error: the Markdown shows up instead of the URL’s image itself.

This is a fascinating article, and happened to coincide with a rereading of the manual of Shoes, an old GUI-building toolkit by the Ruby language community’s Why the Lucky Stiff, which was intended for beginner programmers. Shoes’ approach to graphical layout used a vertical stacks and horizontal flows, each of which was one-dimensional similarly to flexbox. I now realize that their common flaw often requires dramatic changes to their nesting structures whenever something needs to extend past one more neighbor.

Reply?

(a limited set of Markdown is supported)

So, in other words, a grid layout with colspan and rowspan capabilities. Funny how we keep coming back to the stuff we figured out when tables were new in the late 90s.

When display:table was introduced I was pretty excited, hoping to do exactly what you describe here, but they have too many limitations. Seems to me we could accomplish this grid system by simply relaxing some of the restrictions on table layout styling, rather than adding a whole new layout module that'll take five or six years to reach consistent mainstream usage.

I admit the declarative syntax of your template example is a lot more convenient to work with, but nothing quite so simple is part of the actual grid proposal.

Reply?

(a limited set of Markdown is supported)

I originally thought that we could just make table layout better too, but when you dive into it, table layout is CRAZY NUTS. Much better to start fresh with a well-defined layout algorithm that does exactly what you want.

I don't know what you mean by "nothing quite so simple is part of the actual grid proposal". Grid lacks the @ special slot in Level 1, but that's it. Everything else translates directly into existing syntax.

Reply?

(a limited set of Markdown is supported)

body { display: "abb" "acc" "d@e" "fff"; }

#logo { position: a; } #header { position: b; } (etc.)

Reply?

(a limited set of Markdown is supported)

Aren't you trying to use FlexBox for a non-flexible layout? Of course, for that, it's the wrong tool.

FlexBox is great for simple, modern, dynamic content wrapping, resizing and responsive design.

Things you can hardly do with any of the other ways (grid, display:table..., media-query).

Reply?

(a limited set of Markdown is supported)

喜用神什么意思 乙肝不能吃什么东西 骨结核吃什么药效果好 饸饹是什么 一物降一物前面一句是什么
望闻问切什么意思 五行木生什么 炉鼎是什么意思 吃什么对心脏有好处 口里发酸是什么原因
每天喝柠檬水有什么好处 断掌什么意思 兰台是什么意思 嗜睡什么意思 报告是什么意思
血清是什么 雷什么风什么 血小板异常是什么原因 满月回娘家有什么讲究 rapido是什么牌子
艾玛是什么意思啊hcv9jop7ns9r.cn 什么时候闰五月hcv9jop0ns6r.cn 追求是什么意思hcv8jop3ns6r.cn 一等功有什么待遇gysmod.com 为什么爱出汗bjhyzcsm.com
lhrh是什么激素hcv9jop5ns1r.cn 嘴唇舌头发麻什么病兆hcv7jop9ns8r.cn 女人缺铁性贫血吃什么好hcv8jop0ns8r.cn rh血型阳性是什么意思hcv8jop1ns2r.cn 谋生是什么意思hcv7jop9ns4r.cn
蒙字五行属什么hcv8jop1ns9r.cn 血管瘪是什么原因hcv8jop2ns4r.cn pm是什么职位hcv8jop8ns7r.cn 夏季适合种什么花hcv8jop2ns5r.cn 尿路感染吃什么药效果好jiuxinfghf.com
犒赏是什么意思hcv8jop6ns0r.cn 一步之遥是什么意思hcv8jop8ns9r.cn 什么是血浆hcv9jop8ns3r.cn 鳘鱼是什么鱼hcv8jop9ns8r.cn 地球代表什么生肖hcv9jop0ns6r.cn
百度