我正在尝试构建水平和垂直对齐的滑块。我display: flex;
在这段代码中使用:
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
}
<div id="slider">
the content
</div>
我希望div位于屏幕的中央,但不给身体一定的高度,这似乎对我不起作用。我必须使用height: 100vh;
还是有更好的解决方案?
您需要设置height: 100%
上html
也。
html {
height: 100%;
}
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
}
<div id="slider">
the content
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句