gpt4 book ai didi

android - 如何在保护 child 的同时让 parent 居中

转载 作者:行者123 更新时间:2023-11-28 17:33:25 24 4
gpt4 key购买 nike

嘿,我正在尝试将微调器垂直居中高度,因此它位于任何页面的中间。

<body>    
<div class="spinner">
<div class="double-bounce1"></div>
<div class="double-bounce2"></div>
</div>
</body>

.spinner 的样式在这里:

.spinner {
width: 40px;
height: 40px;

position: relative;
margin: 100px auto;
}

我尝试将高度更改为 height:100vh; 但它弄乱了内部 div。如何将中心 div 移动到页面中心并保留我在此处找到的微调器:http://tobiasahlin.com/spinkit/

最佳答案

body{
position: relative;
}

.spinner {
width: 40px;
height: 40px;

position: absolute;
top:50%;
left:50%

margin: -20px 0 0 -20px;
}

带边距:-20px 0 0 -20px;您将到达确切的中心。这是因为,top: 50% 和 left: 50px 将从中心开始显示元素。

关于android - 如何在保护 child 的同时让 parent 居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25564044/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com