#9 CSS3 Flexbox: main style setting

What is Flexbox?

  • Flexbox = Flexible Box
  • "CSS3 Flexbox was designed as a one-dimensional layout model, and as a method that could offer space distribution between items in an interface and powerful alignment capabilities." by Mozilla

Terms


Final Html & CSS

https://ithelp.ithome.com.tw/upload/images/20210909/20130362dspltk4ia4.pnghttps://ithelp.ithome.com.tw/upload/images/20210909/20130362nV21MRpeFO.png
*Just replaced my editor Notepad++ with Visual Studio Code for more useful components.


Display inline, horizontal, and vertical alignment with Flex

1. inline
Before
https://ithelp.ithome.com.tw/upload/images/20210909/201303624JskS5xntc.png

After

main{
    display:flex;
	background-color:#cccccc;
}
main>.item{
	flex:none;/*none = the item is fixed */
	width:300px;margin:10px;
	background-color:#ffcccc;
}

https://ithelp.ithome.com.tw/upload/images/20210909/201303621N8Ts8wETV.png

2. horizontal alignment
Before
https://ithelp.ithome.com.tw/upload/images/20210909/20130362p0M8eS3aZi.png

Afer: try justify-content:center , or flex-end, stretch(default setting, also known as “flex-start”)

main{
    display:flex;
    justify-content:center;
	background-color:#cccccc;
}

https://ithelp.ithome.com.tw/upload/images/20210909/201303621N8Ts8wETV.png

3. vertical alignment
Before
https://ithelp.ithome.com.tw/upload/images/20210909/201303621N8Ts8wETV.png

Afer: try align-items:flex-start , or flex-end, stretch(default setting)

main{
    display:flex;
    justify-content:center;
    align-items:flex-start;
	background-color:#cccccc;
}
  • align-items:flex-start
    https://ithelp.ithome.com.tw/upload/images/20210909/20130362TtwkzHDKnZ.png

  • align-items:flex-end
    https://ithelp.ithome.com.tw/upload/images/20210909/20130362ZXRrNMuJcg.png


Music of Today: Inner by 9m88

Like/Share/Follow

Feel free to comment and share your ideas below to learn together!
If you guys find this article helpful, please kindly do the writer a favor — LIKE this article./images/emoticon/emoticon12.gif


<<:  从零开始学3D游戏设计:入门程序实作 Part.3 逐渐消失的陷阱

>>:  Day09,我也好想用用看Terraform

[DAY 13] 把Google SpreadSheet 当作题库资料库

接下来是如何储存题目、抓出题目、呈现题目 对一个老师来说,很常把资料都放在excel 中 所以可以选...

## Day28 LineBot models小介绍

在linebot之中有提供几种讯息格式, Location Imagemap Template 现在...

[Day32] Angular Material

虽然我们的网站终於整个都布署到云端上,而且功能都正常了,但是,我们的页面外观仍然是丑到不忍直视,虽然...

模型架构--2

SphereFace 在2017年发表在CVPR的文章,改进原先使用softmax作为loss fu...

Day 21 - 嵌入 AlexeyAB/darknet 的 Python

Day 21 - 嵌入 AlexeyAB/darknet 的 Python 如同先前的 Joseph...