CSS Flexible Box Layout - CSS: Cascading Style Sheets 编辑

CSS Flexible Box Layout is a module of CSS that defines a CSS box model optimized for user interface design, and the layout of items in one dimension. In the flex layout model, the children of a flex container can be laid out in any direction, and can “flex” their sizes, either growing to fill unused space or shrinking to avoid overflowing the parent. Both horizontal and vertical alignment of the children can be easily manipulated.

Basic Example

In the following example a container has been set to display: flex, which means that the three child items become flex items. The value of justify-content has been set to space-between in order to space the items out evenly on the main axis. An equal amount of space is placed between each item with the left and right items being flush with the edges of the flex container. You can also see that the items are stretching on the cross axis, due to the default value of align-items being stretch. The items stretch to the height of the flex container, making them each appear as tall as the tallest item.

Reference

CSS Properties

Alignment Properties

The properties align-content, align-self, align-items and justify-content initially appeared in the Flexbox specification, but are now defined in Box Alignment. The Flexbox spec now refers to the Box Alignment specification for up to date definitions. Also additional alignment properties are now defined in Box Alignment.

Glossary entries

Guides

Basic Concepts of Flexbox
An overview of the features of Flexbox
Relationship of Flexbox to other layout methods
How Flexbox relates to other layout methods, and other CSS specifications
Aligning items in a flex container
How the Box Alignment properties work with Flexbox.
Ordering flex items
Explaining the different ways to change the order and direction of items, and covering the potential issues in doing so.
Controlling Ratios of flex items along the main axis
Explaining the flex-grow, flex-shrink and flex-basis properties.
Mastering wrapping of flex items
How to create flex containers with multiple lines and control the display of the items in those lines.
Typical use cases of Flexbox
Common design patterns that are typical Flexbox use cases.
Backwards compatibility of Flexbox
Browser status of Flexbox, interoperability issues and supporting older browsers and versions of the spec

Specifications

SpecificationStatusComment
CSS Flexible Box Layout ModuleCandidate RecommendationInitial definition.

See also

Flexbugs
a community-curated list of Flexbox browser bugs and workarounds
Cross-browser Flexbox mixins
This article provides a set of mixins for those who want to create cross-browser Flexbox experiences that even work in older browser that don't support the modern Flexbox syntax

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:89 次

字数:7253

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文