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

Navigation


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


Thanks for your reading. Welcome to subscribe my blog by Github.

Post Time: 2019/2/12
Category: Technology/FrontEnd/CSS
Author all rights reserved reprint please indicate the source no commercial reprint
Copyright © 2017-2021Terry SuALL RIGHTS RESERVED