justify-content 用于设置或检索弹性盒子元素在主轴方向上的对齐方式。

属性值:flex-start

属性值:flex-end

属性值:center

属性值:space-between

属性值:space-around

通过具体代码示例各个属性值的效果。

HTML结构

<div class="container flex">
<div class="items">A</div>
<div class="items">B</div>
<div class="items">C</div>
<div class="items">D</div>
<div class="items">E</div>
<div class="items">F</div>
<div class="items">G</div>
<div class="items">H</div>
</div>

CSS样式:

.container {
display: flex;
width: 1000px;
height: 500px;
background-color: gray;
margin: 20px auto;
} .items {
width: 300px;
height: 100px;
text-align: center;
line-height: 100px;
font-weight:;
color: gray;
} .items:nth-child(1) {
background-color: #ff0000;
} .items:nth-child(2) {
background-color: #ffff00;
} .items:nth-child(3) {
background-color: #ff00ff;
} .items:nth-child(4) {
background-color: #0000ff;
} .items:nth-child(5) {
background-color: #14a9ee;
} .items:nth-child(6) {
background-color: #71a03b;
} .items:nth-child(7) {
background-color: #c323eb;
} .items:nth-child(8) {
background-color: #ffffff;
}

属性值:flex-start

描述:默认值。项目位于容器的开头。

.flex {
flex-wrap: wrap;
justify-content: flex-start;
}

属性值:flex-end

描述:项目位于容器的结尾。

.flex {
flex-wrap: wrap;
justify-content: flex-end;
}

属性值center

描述:项目位于容器的中心。

.flex {
flex-wrap: wrap;
justify-content: center;
}

属性值:space-between

描述:项目位于各行之间留有空白的容器内。

.flex {
flex-wrap: wrap;
justify-content: space-between;
}

属性值:space-around

描述:项目位于各行之前、之间、之后都留有空白的容器内。

.flex {
flex-wrap: wrap;
justify-content: space-around;
}

justify-content属性的更多相关文章

  1. CSS3中的counter和content属性,一些简单的内容显示就不需要JS去实现了

    HTML的代码 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www ...

  2. css3 的content 属性

    content属性想必大家都熟悉了,一般结合伪类一起使用,表示显示的内容 例如:.box:before{content:"hello";width:100px;line-heigh ...

  3. Easyui tabs的herf和content属性

    在backstage.jsp页面中我写了一个方法,用于在指定位置添加面板(id为msg的地方)function addTab(t,h){ if($('#msg').tabs('exists',t)){ ...

  4. CSS Content 属性

    content 属性,用在after,before伪元素上,用于在选中的元素前后插入内容. 插入的内容多种多样, 纯文字 h1::after{ content:"h1后插入内容" ...

  5. CSS3使用content属性来插入项目编号

    首先可以使用before选择器与after选择器的content属性在元素的前面或者后面插入文字和图像,这里我记录的是利用这个content属性来在项目前插入项目编号,同时可以利用content属性在 ...

  6. CSS魔法堂:一起玩透伪元素和Content属性

    前言  继上篇<CSS魔法堂:稍稍深入伪类选择器>记录完伪类后,我自然而然要向伪元素伸出"魔掌"的啦^_^.本文讲讲述伪元素以及功能强大的Contet属性,让我们可以通 ...

  7. 浅析requests库响应对象的text和content属性

    在做爬虫时请求网页的requests库是必不可少的,我们常常会用到 res = resquests.get(url) 方法,在获取网页的html代码时常常使用res的text属性: html = re ...

  8. WPF:为什么使用ContentPresenter.ContentSource而不是Content属性?

    因为ContentPresenter.ContentSource比Content属性加一个TemplateBinding看起来更方便?不仅仅是这些,实际上如果用ContentSource的话,Cont ...

  9. CSS3 content属性学习

    css3中出现了 ":before",":after"伪类, 你可以这样写: h1:after{ content:'h1后插入的文本'; ... } 这两个选择 ...

  10. 浅谈 easyui tabs 的href和content属性

    众所周知,jQuery Easyui 的tabs插件有两种方式加载某个tab(标签页)上的内容:“href远程请求”和“content本地内容”,本文就两种方式的优缺点进行简单分析和思考. 两者特点: ...

随机推荐

  1. SpringBoot入门系列~Spring-Data-JPA自动建表

    1.pom.xml引入Spring-Data-Jpa和mysql依赖 <!-- Spring-data-jpa依赖 --> <dependency> <groupId&g ...

  2. MySQL查看表结构及查看建表语句

    查看表结构:desc 表名 mysql> use recommend; Database changed mysql> desc user; +--------------+------- ...

  3. msp430入门编程01

    msp430单片机最小系统 msp430入门学习 msp430入门编程

  4. Organize Your Train part II 字典树(此题专卡STL)

    Organize Your Train part II Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8787   Acce ...

  5. Eclipse替换find/Replace

    使用快捷键:ctrl+F       replaceAll

  6. 2017-10-01-afternoon

    T1 一道图论好题(graph) Time Limit:1000ms   Memory Limit:128MB 题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带 ...

  7. 2、Java并发性和多线程-多线程的优点

    以下内容转自http://ifeve.com/benefits/: 尽管面临很多挑战,多线程有一些优点使得它一直被使用.这些优点是: 资源利用率更好 程序设计在某些情况下更简单 程序响应更快 资源利用 ...

  8. linux内核CFS进程调度策略

    一.概述 首先简介一下主要的设计思路, CFS思路非常easy.就是依据各个进程的权重分配执行时间(权重怎么来的后面再说). 进程的执行时间计算公式为: 分配给进程的执行时间 = 调度周期 * 进程权 ...

  9. 踩坑录-IDEA编辑器:找不到TomcatService或ApplicationServers----TomcatService使用指南

    一.找不到TomcatService或ApplicationServers Setp1. 检查IDEA版本 检查IDEA版本是否为Ultimate(终极版需要激活),Community(社区版免费无需 ...

  10. 关于android中的单位(dp、sp)

    android让人头疼的适配问题. --------- Android 中的单位大概有这些: 经常使用的dip.sp.有时候用到px. --------- 介绍两个类: TypedValue:有一些单 ...