搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
HTML/CSS
CSS3教程
CSS3基础教程
源代码
清空
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Flex项目沿着十字轴对齐示例- div.cn 基础教程</title> <style> .flex-container { width: 500px; min-height: 300px; margin: 0 auto; font-size: 32px; border: 1px solid #666; /* Safari */ display: -webkit-flex; -webkit-align-items: center; /* Standard syntax */ display: flex; align-items: center; } .flex-container div{ padding: 10px; } .item1 { width: 75px; height: 100px; background: #e84d51; } .item2 { width: 125px; height: 200px; background: #7ed636; } .item3 { width: 175px; height: 150px; background: #2f97ff; } </style> </head> <body> <div class="flex-container"> <div class="item1">1</div> <div class="item2">2</div> <div class="item3">3</div> </div> <p> <strong>注意</strong>:尝试使用align-items属性的其他值,例如“ flex-start”,“ flex-end”,“ baseline”和“ stretch”,以了解其如何对齐项目 在flex容器中。</p> </body> </html>
运行结果