Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
css justify-content属性怎么用_创想鸟

css justify-content属性怎么用

css justify-content 用于设置或检索弹性盒子元素在主轴(横轴)方向上的对齐方式,对齐方式有:位于容器的开头、位于容器的结尾、位于容器的中心、均匀分布等等。

css justify-content属性怎么用

css justify-content属性怎么用?

justify-content 用于设置或检索弹性盒子元素在主轴(横轴)方向上的对齐方式。可以使用 align-content 属性对齐交叉轴上的各项(垂直)。

语法:

立即学习“前端免费学习笔记(深入)”;

justify-content: flex-start|flex-end|center|space-between|space-around|initial|inherit;

属性值:

● flex-start:默认值。项目位于容器的开头。

flex-start.jpg

● flex-end:项目位于容器的结尾。

flex-end.jpg

● center:项目位于容器的中心。

center.jpg

● space-between:项目位于各行之间留有空白的容器内,即均匀分布在线上; 第一项是在起始行,最后一项是在结束行。

space-between.jpg

● space-around:项目位于各行之前、之间、之后都留有空白的容器内。

space-around.jpg

● initial:设置该属性为它的默认值。

● inherit:从父元素继承该属性。

css justify-content属性 示例

.flex-container {  padding: 0;  margin: 0;  list-style: none;  display: flex;}.flex-start {   justify-content: flex-start; }.flex-end {   justify-content: flex-end; }  .flex-end li {  background: gold;}.center {   justify-content: center; }  .center li {  background: deepskyblue;}.space-between {   justify-content: space-between; }  .space-between li {  background: lightgreen;}.space-around {   justify-content: space-around; }.space-around li {  background: hotpink; }.space-evenly {   justify-content: space-evenly; }.space-evenly li {  background: #bada55; }.flex-item {  background: tomato;  padding: 5px;  width: 60px;  height: 50px;  margin: 5px;  line-height: 50px;  color: white;  font-weight: bold;  font-size: 2em;  text-align: center;}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

效果图:

2.jpg

说明:

红色列表是justify-content属性设置为 flex-start

黄色是justify-content属性设置为 flex-end

蓝色是justify-content属性设置为 center

绿色是justify-content属性设置为 space-between

粉红色是justify-content属性设置为 space-around

浅绿色是justify-content属性设置为 space-evenly

以上就是css justify-content属性怎么用的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1614665.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
css clear属性怎么用
上一篇 2025年12月24日 04:28:24
css max-height属性怎么用
下一篇 2025年12月24日 04:28:30

相关推荐

发表回复

登录后才能评论
关注微信