首页 > 文章列表 > css中flex是什么

css中flex是什么

css flex
139 2022-08-06

1、flex是flexible的缩写,意思为弹性布局,用来为盒模型提供灵活性。

任何一个容器都可以指定为 flex 布局(包括行内元素)

2、利用flex实现居中布局,实现简易的弹性伸缩布局。

实例

<style>
/* 使用 flex 进行布局 */
.wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400px;
    width: 100%;
    border-bottom: 1px solid black;
}
.box {
    height: 200px;
    width: 200px;
    background: red;
}
</style>
<body>
<div>
    <div></div>
</div>
</body>

本文教程操作环境:windows7系统、css3版,DELL G3电脑。