We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
之前总结过水平垂直居中的方法, 以及CSS-tricks中也有清晰的总结。
最近发现项目中其他人写的样式中大量使用了display:table-cell去实现水平垂直居中.
display:table-cell
.father{ display: table-cell; width: 500px; height: 300px; background-color: #de3; vertical-align: middle; text-align: center; } .child{ display: inline-block; max-width:400px; max-height:200px; background-color: #fd2; }
优势在于不会有position:absolute的负面影响
以及实现多行元素垂直居中:
.father{ display: table-cell; width: 100px; height: 200px;//高度设置无效 background-color: #de3; vertical-align: middle; text-align: center; word-break: normal; }
这一方法的问题在于:
多行文字垂直居中:
.flex-center-vertically { display: flex; justify-content: center; flex-direction: column; height: 400px; } .ghost-center { position: relative; } .ghost-center::before { content: " "; display: inline-block; height: 100%; width: 1%; vertical-align: middle; } .ghost-center p { display: inline-block; vertical-align: middle; }
The text was updated successfully, but these errors were encountered:
naseeihity
No branches or pull requests
之前总结过水平垂直居中的方法,
以及CSS-tricks中也有清晰的总结。
最近发现项目中其他人写的样式中大量使用了
display:table-cell
去实现水平垂直居中.优势在于不会有position:absolute的负面影响
以及实现多行元素垂直居中:
这一方法的问题在于:
多行文字垂直居中:
The text was updated successfully, but these errors were encountered: