- JavaScript by Example
- Dani Akash S
- 315字
- 2021-07-02 18:39:09
Flexbox - a quick introduction
In the flexbox layout system, you declare a parent div with a CSS property display: flex, which allows you to control how you want to position its children elements.
Once you declare display: flex, the div element becomes a flexbox with two axes. The Main axis along with the content are placed with the Cross axis, which is perpendicular to the Main axis. You can use the following CSS properties in the parent flexbox to change the position of child elements (flex items):
- flex-direction: Create the Main axis either horizontally (row) or vertically (column)
- justify-content: Specify how flex items are placed on the Main axis
- align-items: Specify how flex items are placed on the Cross axis
- flex-wrap: Specify how to handle flex items when there is not enough space to display them in a single row
You can also apply some flex properties to flex items, such as:
- align-self: Specify how to place the specific flex item on the Cross axis
- flex: The relative size of the flex item with respect to other flex items (if you have two items with flex: 2 and flex: 1 respectively, the first one will be twice the size of the second one)
All those should sound confusing, but the easiest way to understand flexbox is to use online flexbox playgrounds. Google some flexbox playgrounds available online to experience how different properties of flexbox work. One such playground can be found at http://flexboxplayground.catchmyfame.com/.
To learn flexbox, refer to the following pages:
- Mozilla Developer Network: https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox
- W3Schools: https://www.w3schools.com/css/css3_flexbox.asp
- Flexbox Froggy (a game for learning flexbox): https://flexboxfroggy.com/
- C及C++程序設計(第4版)
- SPSS數據挖掘與案例分析應用實踐
- Go語言高效編程:原理、可觀測性與優化
- 劍指JVM:虛擬機實踐與性能調優
- Java游戲服務器架構實戰
- Learning Laravel 4 Application Development
- The DevOps 2.4 Toolkit
- Python數據結構與算法(視頻教學版)
- Learning JavaScript Data Structures and Algorithms
- 蘋果的產品設計之道:創建優秀產品、服務和用戶體驗的七個原則
- 創意UI:Photoshop玩轉APP設計
- Docker:容器與容器云(第2版)
- Spring Data JPA從入門到精通
- Java EE實用教程
- The Applied Data Science Workshop