苏溪云
Common Flex Use Cases

Flex is very useful and commonly used in daily development, here summarizes several common use cases:

  • navigation
  • center an element horizontally or vertically
  • together with input
  • responsive website layout
  • display icons in multi-lines


Center an Element Horizontally or Vertically


Btw, using place-items: center in grid layout to center an element is more elegant.

.container {
  display: grid;
  place-items: center;
  ...
}
...

Together with Input

Input's width is adjusted automatically.

Responsive Website Layout

One side's with is fixed, the other is flexible.

Display Icons in Multi-lines


感谢你的阅读。欢迎通过微信(扫描下方二维码)或Github订阅我的博客。

微信公众号:苏溪云的博客

发布时间: 2/12/2019
分类: 技术/前端/CSS
作者版权所有,转载请注明出处,禁止商业转载