css教程网 css教程网365css.cn
公告为您打开互联网世界的窗户关于本站
首页/属性速查/布局与定位

justify-content

主轴上的对齐与剩余空间分配。

语法
justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly
常用值
flex-start / flex-end / center / space-between / space-around / space-evenly
初始值
flex-start(grid 为 normal)
继承
否

运行效果

示例改成别的值试试,差异一眼能看出来
查看代码
HTML
<div class="jc"><i>1</i><i>2</i><i>3</i></div>
CSS
.jc { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 12px; background: #f6f8fc; border-radius: 10px; }
.jc i { width: 34px; height: 34px; border-radius: 7px; background: #2b57ff; color: #fff; display: grid; place-items: center; font: 600 11px/1 ui-monospace, monospace; font-style: normal; }

使用要点

  • space-between 首尾贴边,space-around 两端留半份,space-evenly 所有间隙相等。
  • grid 容器里它作用于整组列轨道,与 justify-items(单元格内对齐)不同。