gpt4 book ai didi

html - div 内的中心加载器

转载 作者:太空宇宙 更新时间:2023-11-03 19:48:42 27 4
gpt4 key购买 nike

我有这个装载机:

.loader_ajax_small {
border: 2px solid #f3f3f3 !important;
border-radius: 50%;
border-top: 2px solid #2D2D2D !important;
width: 29px;
height: 29px;
-webkit-animation: spin_loader_ajax_small 2s linear infinite;
animation: spin_loader_ajax_small 2s linear infinite;
}

@-webkit-keyframes spin_loader_ajax_small {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin_loader_ajax_small {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

但我不明白如何在 div 内水平居中,例如:

enter image description here

如您所见,它在左侧,但我希望它居中,我该怎么做?

最佳答案

.loader_ajax_small 中为父 div 的中心添加了 margin: 0 auto;

.loader {
border: 1px solid #ccc;
padding: 20px;
}
.loader_ajax_small {
border: 2px solid #f3f3f3 !important;
border-radius: 50%;
border-top: 2px solid #2D2D2D !important;
width: 29px;
height: 29px;
margin: 0 auto;
-webkit-animation: spin_loader_ajax_small 2s linear infinite;
animation: spin_loader_ajax_small 2s linear infinite;
}

@-webkit-keyframes spin_loader_ajax_small {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin_loader_ajax_small {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
<div class="loader">
<div class="loader_ajax_small"></div>
</div>

或使用display: flex;

.loader {
border: 1px solid #ccc;
padding: 20px;
display: flex;
justify-content: center;
}
.loader_ajax_small {
border: 2px solid #f3f3f3 !important;
border-radius: 50%;
border-top: 2px solid #2D2D2D !important;
width: 29px;
height: 29px;
-webkit-animation: spin_loader_ajax_small 2s linear infinite;
animation: spin_loader_ajax_small 2s linear infinite;
}

@-webkit-keyframes spin_loader_ajax_small {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin_loader_ajax_small {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
<div class="loader">
<div class="loader_ajax_small"></div>
</div>

关于html - div 内的中心加载器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45794595/

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