display:flex属性水平居中
时间: 2023-09-20 10:11:09 浏览: 153
浅谈CSS3中display属性的Flex布局的方法
要使display:flex属性水平居中,你可以使用justify-content: center;属性。这将使flex容器中的子元素在水平方向上居中对齐。另外,你还可以使用align-items: center;属性来使子元素在垂直方向上居中对齐。如果你想要调整子元素之间的距离,你可以使用margin属性来设置子元素的外边距。另外,如果你想要调整子元素在容器中的位置,你可以使用align-content属性来控制元素的堆叠位置,例如align-content: flex-start;可以使元素位于容器的开头。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [display:flex 元素垂直居中,有间距,右对齐,gap属性](https://blog.csdn.net/xutongbao/article/details/119994687)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [css使用flexbox布局容器内多元素水平居中](https://download.csdn.net/download/weixin_38703968/13672753)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [css display:flex 属性](https://blog.csdn.net/qq_40716795/article/details/114028424)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文