您好,我的网站仍在尝试从 API 获取数据时,我正在为我的网站制作加载程序。
.in-loader {
position: fixed;
z-index: 999;
height: 2em;
width: 2em;
overflow: visible;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.in-loader:before {
content: '';
display: block;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: white;
}
}
div.in-loader {
position: fixed;
background: white;
width: 100%;
height: 100%;
z-index: 1000;
opacity: 0;
transition: opacity 0.5s ease;
overflow: hidden;
pointer-events: none;
display: flex;
align-items: center;
justify-content: center;
}
div.in-loader div {
width: 1rem;
height: 1rem;
margin: 2rem 0.3rem;
background: #fd6a4f;
border-radius: 50%;
-webkit-animation: 0.9s bounce infinite alternate;
animation: 0.9s bounce infinite alternate;
}
div.in-loader div:nth-child(2) {
-webkit-animation-delay: 0.3s;
animation-delay: 0.3s;
}
div.in-loader div:nth-child(3) {
-webkit-animation-delay: 0.6s;
animation-delay: 0.6s;
}
@-webkit-keyframes bounce {
to {
opacity: 0.3;
transform: translate3d(0, -1rem, 0);
}
}
@keyframes bounce {
to {
opacity: 0.3;
transform: translate3d(0, -1rem, 0);
}
}
<div class="in-loader">
<div></div>
<div></div>
<div></div>
</div>
当我运行这段代码时,它会显示加载器动画。但我认为 div 是垂直堆栈。我想要的是水平堆栈。我试过`display:inline;',但它没有改变任何东西。任何答案将不胜感激。谢谢
答案 0 :(得分:0)
只需将 CSS 调整为以下内容
.in-loader {
position: fixed;
z-index: 999;
height: 2em;
width: 6em; /* We make the container wider */
overflow: visible;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
div.in-loader div {
width: 1rem;
height: 1rem;
margin: 2rem 0.3rem;
background: #fd6a4f;
border-radius: 50%;
-webkit-animation: 0.9s bounce infinite alternate;
animation: 0.9s bounce infinite alternate;
display: inline-block; /* Then we make the inner elements displayed as inline-blocks */
}
让元素正确级联有两个方面。
您在第二个方面是正确的,但在第一个方面错了。