Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Flexbox

From Wikipedia, the free encyclopedia
(Redirected fromCSS Flexible Box Layout)
CSS3 web layout mode
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Flexbox" – news ·newspapers ·books ·scholar ·JSTOR
(April 2014) (Learn how and when to remove this message)
Flexbox
CSS Flexible Box Layout
StatusCandidate Recommendation (CR)
Year started23 July 2009 (2009-07-23)[1]
Latest versionLevel 1[2]
November 9, 2018 (2018-11-09)[2]
Preview versionWorking Draft
March 25, 2021 (2021-03-25)[3]
Organization
CommitteeCSS Working Group[2]
Editors
  • Tab Atkins Jr.
  • Elika J. Etemad
  • Rossen Atanassov
Former editors
    • Alex Mogilevsky
    • L. David Baron
    • Neil Deakin
    • Ian Hickson
    • David Hyatt
[2]
Base standardsCSS
Websitewww.w3.org/TR/css-flexbox-1/

CSS Flexible Box Layout, commonly known asFlexbox,[2] is aCSS web layout model.[4] It is in theW3C's candidate recommendation (CR) stage.[2] The flex layout allowsresponsive elements within a container to be automatically arranged depending on viewport (device screen) size.

Cascading Style Sheets
Concepts
Philosophies
Tools
Comparisons

Concepts

[edit]

Mostweb pages are written in a combination ofHTML (Hypertext Markup Language),JavaScript andCSS (Cascading Style Sheets). In short, HTML specifies thecontent and logical structure of the page, while the CSS specifieshow it looks: its colors, fonts, formatting, layout, and styling.

CSS flex-box layout is a particular way to specify the layout of HTML pages.

One of the most defining features of the flex layout is its ability to form-fit, based on its viewing environment. Flex boxes can adjust in size—either decreasing, to avoid unnecessarily monopolizing space, or increasing to make room for contents to fit within its boundaries. Moreover, the flex layout is less restrictive in terms of content flow than that of other CSS layout models, which are generally uni-directional. The flex directional flow can be specified rightwards, leftwards, upwards, or downwards. Individual items within a flex container may also be automatically rearranged to suit the available layout space.[3]

History

[edit]

From the late 2000s onward, the intensive use of the Web bymobile agents motivated "liquid layouts" andresponsive elements for the growing variety ofscreen sizes.[5] In the 2010s, the intensive use of popularJavaScript layoutframeworks, such asBootstrap, inspired CSS flex-box and grid layout specifications.[6]

CSS modules included solutions akin to this, like flexbox[2] andgrid.[7] Flexbox is originally based on a similar feature available inXUL, the user interface toolkit fromMozilla, used inFirefox.[8][9]

As of December 2022[update], 99.68% of installed browsers (99.59% of desktop browsers and 100% of mobile browsers) support CSS Flexible Box Layout.[10]

Terminology

[edit]

The following terms are associated with the flexbox layout model.

Flex container
Parent element that holds all flex items. Using the CSS display property, the container can be defined as either flex or inline-flex.
Flex item
Any direct child element held within the flex container is considered a flex item. Any text within the container element is wrapped in an unknown flex item.
Axes
Each flex box contains two axes: the main and cross axes. Themain axis is the axis on which the items align with each other. Thecross axis is perpendicular to the main axis.
Flex-direction
Establishes main axis. Possible arguments: row (default), row-reverse, column, column-reverse.
Justify-content
Determines how content gets placed on the main axis on the current line. Optional arguments: left, right, center, space-between, space-around.
Align-items
Determines the default for how flex items get placed on the cross axis on each line.
Align-content
Determines the default for how cross axis lines are aligned.
Align-self
Determines how a single item is placed along the cross axis. This overrides any defaults set by align-items.

Directions

[edit]
cross-start
cross-end
Thecross-start/cross-end sides determine where flex lines get filled with flex items from cross-start to cross-end.
main-start
main-end
Themain-start/main-end sides determine where to start placing flex items within the flex container, starting from the main-start end and going to the main-end end.
Order
Places elements in groups and determines which order they are to be placed in within the container.
Flex-flow
Shorthands flex-direction and flex-wrap to place the flex content.

Lines

[edit]
Lines
Flex items can either be placed on a singular line or on multiple lines as defined by the flex-wrap property, which controls both the direction of the cross axis and how lines stack within the container.

Dimensions

[edit]
Main size
Cross size
Main size andcross size are the height and width of the flex container, each dealing with the main and cross axes respectively.

Usage

[edit]

Designating an element as a flex element requires setting the element's CSS display property to either flex or inline-flex, as follows:

display:flex;

Or:

display:inline-flex;

By setting the display to one of the two values above, an element becomes a flex container and its children, flex items. Setting the display to flex makes the container ablock-level element, while setting the display to inline-flex makes the container aninline-level element.[4]

Align to center

[edit]

One of flexbox's advantages is the ability to easily align items within the container to the center of a page, both vertically and horizontally.

display:flex;align-items:center;justify-content:center;

References

[edit]
  1. ^"CSS Flexible Box Layout Module Level 1 Publication History - W3C".W3C. n.d. Retrieved2021-04-08.
  2. ^abcdefgAtkins Jr., Tab; Etemad, Elika J.; Atanassov, Rossen; Mogilevsky, Alex; Baron, L. David; Deakin, Neil; Hickson, Ian; Hyatt, David, eds. (2018-11-09)."CSS Flexible Box Layout Module Level 1".W3C. Retrieved2021-04-08.
  3. ^abAtkins Jr, Tab; Etemad, Elika J.; Atanassov, Rossen; Mogilevsky, Alex; Baron, L. David; Deakin, Neil; Hickson, Ian; Hyatt, David, eds. (2021-03-25)."CSS Flexible Box Layout Module Level 1".CSS Working Group Editor Drafts. Retrieved2021-04-08.
  4. ^ab"Basic concepts of flexbox".MDN Web Docs. n.d. Retrieved2021-04-08.
  5. ^Bail, Jeff (2012-10-23)."Use CSS media queries to create responsive websites".IBM Developer. Archived fromthe original on 2020-10-13. Retrieved2021-04-08.
  6. ^Shepherd, Richard (2011-09-19)."CSS3 Flexible Box Layout: Everything I Wish I Knew When I Started".Smashing Magazine. Retrieved2021-04-08.
  7. ^Atkins Jr., Tab; Etemad, Elika J.; Atanassov, Rossen; Brufau, Oriol; Mogilevsky, Alex; Cupp, Phil, eds. (2020-12-18)."CSS Grid Layout Module Level 1".W3C. CSS Working Group. Retrieved2021-04-08.
  8. ^Shepherd, Richard (2011-09-19)."CSS3 Flexible Box Layout: Everything I Wish I Knew When I Started".Smashing Magazine. Retrieved2021-04-08.
  9. ^Flexible Box Layout Module, W3C Working Draft, 23 July 2009
  10. ^"CSS Flexible Box Layout Module".Can I use. Retrieved2020-09-03.
Products,
standards
Recommendations
Notes
Working drafts
Guidelines
Initiative
Deprecated
Obsoleted
Groups,
organizations
Elected
Working
Community, business
Closed
Software
Browsers
Conferences
Retrieved from "https://en.wikipedia.org/w/index.php?title=Flexbox&oldid=1297016613"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp