小白教程
所有教程
关于
Search
172.69.7.82
172.69.7.82
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Css3 pr justify content”的源代码
本页内容
上一节:
Css3_pr_align_self
下一节:
Css3_pr_order
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:justify-content}}[[Category:css reference|111]] = CSS justify-content 属性 = [[css reference|CSS 参考手册]] 在弹性盒对象的 <div> 元素中的各项周围留有空白: <sample title="" desc="" lang="html" hererun="1"> div { display: flex; justify-content: space-around; } </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> #main { width: 400px; height: 150px; border: 1px solid #c3c3c3; display: -webkit-flex; /* Safari */ -webkit-justify-content: space-around; /* Safari 6.1+ */ display: flex; justify-content: space-around; } #main div { width: 70px; height: 70px; } </style> </head> <body> <div id="main"> <div style="background-color:coral;"></div> <div style="background-color:lightblue;"></div> <div style="background-color:khaki;"></div> <div style="background-color:pink;"></div> </div> <p><b>注意:</b> Internet Explorer 10 及更早版本浏览器不支持 justify-content 属性。</p> <p><b>注意:</b> Safari 6.1 及更新版本通过 -webkit-justify-content 属性支持该属性。</p> </body> </html> </run> == 浏览器支持 == 表格中的数字表示支持该属性的第一个浏览器的版本号。 紧跟在 -webkit-, -ms- 或 -moz- 后的数字为支持该前缀属性的第一个版本。 {| class="table table-striped table-hover" ! 属性 ! Chrome ! Internet Explorer / Edge ! Firefox ! Safari ! Opera |- | justify-content | 29.021.0 -webkit- | 11.0 | 28.018.0 -moz- | 9.06.1 -webkit- | 17.0 |} == 定义和用法 == justify-content 用于设置或检索弹性盒子元素在主轴(横轴)方向上的对齐方式。 '''提示:'''使用 align-content 属性对齐交叉轴上的各项(垂直)。 {| class="table table-striped table-hover" |width="50%"| 默认值: |width="50%"| flex-start |- | 继承: | 否 |- | 可动画化: | 否。请参阅 [[css animatable|可动画化(animatable)]]。 |- | 版本: | CSS3 |- | JavaScript 语法: | object.style.justifyContent="space-between" <run name=""> <!DOCTYPE html> <html> <head> <style> #main { width: 400px; height: 150px; border: 1px solid #000000; display: flex; justify-content: space-around; } #main div { width: 70px; height: 70px; } </style> </head> <body> <div id="main"> <div style="background-color:coral;"></div> <div style="background-color:lightblue;"></div> <div style="background-color:khaki;"></div> <div style="background-color:pink;"></div> </div> <p>点击“尝试一下”按钮,设置 justifyContent 属性的值为 "space-between"。</p> <button onclick="myFunction()">尝试一下</button> <script> function myFunction() { document.getElementById("main").style.justifyContent = "space-between"; } </script> <p><b>注意:</b>Internet Explorer、Firefox 和 Safari 不支持 justifyContent 属性。</p> </body> </html> </run> |} <sample title="" desc="" lang="html" hererun="1"> /* 对齐方式 */ justify-content: center; /* 居中排列 */ justify-content: start; /* 从行首开始排列 */ justify-content: end; /* 从行尾开始排列 */ justify-content: flex-start; /* 从行首起始位置开始排列 */ justify-content: flex-end; /* 从行尾位置开始排列 */ justify-content: left; /* 一个挨一个在对齐容器得左边缘 */ justify-content: right; /* 元素以容器右边缘为基准,一个挨着一个对齐, */ /* 基线对齐 */ justify-content: baseline; justify-content: first baseline; justify-content: last baseline; /* 分配弹性元素方式 */ justify-content: space-between; /* 均匀排列每个元素 首个元素放置于起点,末尾元素放置于终点 */ justify-content: space-around; /* 均匀排列每个元素 每个元素周围分配相同的空间 */ justify-content: space-evenly; /* 均匀排列每个元素 每个元素之间的间隔相等 */ justify-content: stretch; /* 均匀排列每个元素 'auto'-sized 的元素会被拉伸以适应容器的大小 */ /* 溢出对齐方式 */ justify-content: safe center; justify-content: unsafe center; /* 全局值 */ justify-content: inherit; justify-content: initial; justify-content: unset; </sample> == CSS 语法 == <pre> justify-content: flex-start|flex-end|center|space-between|space-around|initial|inherit;</pre> == 属性值 == {| class="table table-striped table-hover" ! 值 ! 描述 ! 测试 |- | flex-start | 默认值。从行首起始位置开始排列。 | [[playit.php?f=playcss_justify content&preval=flex start|测试 »]] |- | flex-end | 从行尾位置开始排列。 | [[playit.php?f=playcss_justify content&preval=flex end|测试 »]] |- | center | 居中排列。 | [[playit.php?f=playcss_justify content&preval=center|测试 »]] |- | space-between | 均匀排列每个元素,首个元素放置于起点,末尾元素放置于终点。 | [[playit.php?f=playcss_justify content&preval=space between|测试 »]] |- | space-evenly | 均匀排列每个元素,每个元素之间的间隔相等。 | [[playit.php?f=playcss_justify content&preval=space evenly|测试 »]] |- | space-around | 均匀排列每个元素,每个元素周围分配相同的空间。 | [[playit.php?f=playcss_justify content&preval=space around|测试 »]] |- | initial | 设置该属性为它的默认值。请参阅 [[css initial|initial]]。 | [[playit.php?f=playcss_justify content&preval=initial|测试 »]] |- | inherit | 从父元素继承该属性。请参阅 [[css inherit|inherit]]。 | |} == 相关文章 == CSS 参考手册:[[css3 pr align content|align-content 属性]] CSS 参考手册:[[css3 pr align items|align-items 属性]] CSS 参考手册:[[css3 pr align self|align-self 属性]] [[css reference|CSS 参考手册]]
返回至“
Css3 pr justify content
”。
上一节:
Css3_pr_align_self
下一节:
Css3_pr_order