html - flexbox 仅垂直对齐
问题描述
我在当前垂直和水平居中的父 div 中有一个子 div:
CSS
.parent {
height: 100vh;
background: #e1e1e1;
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
}
.child {
width: 300px;
height: 50px;
background: blue;
}
HTML
<div class="parent">
<div class="child">
<p>Content</p>
</div>
</div>
我想删除水平居中的孩子,只让它垂直居中。
解决方案
推荐阅读
- python - 重塑锯齿状数组并用零填充
- robotframework - 如何在另一个用户定义的关键字中引用机器人框架用户定义的关键字
- python - 如何裁剪面部及其部分?
- javascript - 在同一页面中多次使用相同的 LitElement
- python - 如何写 np.where 变量等于列表中的任何一个,做点什么?
- c# - C# 无法从方法返回错误消息
- typescript - TypeScript Transformers:转换导入的文件
- php - 如何在drupal中使这条消息多语言?
- javascript - 如何从用户创建的列表(购物车)中删除元素
- reactjs - Chrome 调试器已暂停