我正在制作一个加载动画。我的问题是,只有在Chrome中才能将这些放在flexbox中。:before和:after在火狐中位于父目录的底部,在safari中位于顶部。
#pulse-box {
width: 100%;
height: 100px;
display: flex;
justify-content: center;
align-items: center;
}
#pulse {
position: relative;
width: 12.5px;
height: 50px;
animation: pulse 750ms infinite;
animation-delay: 250ms;
display: flex;
justify-content: center;
align-items: center;
}
#pulse:before,
#pulse:after {
content: '';
position: absolute;
display: block;
width: 12.5px;
height: 33.3px;
background: #efefef;
animation: pulse 750ms infinite;
}
#pulse:before {
left: -25px;
/* -(pulse height / 1.5) */
}
#pulse:after {
left: 25px;
/* (pulse height / 1.5) */
animation-delay: 500ms;
}
@keyframes pulse {
0%,
10% {
background: #efefef;
}
50% {
background: #5b5b5b;
}
}<div id="pulse-box">
<div id="pulse" />
</div>
您也可以在我制作的jsfiddle中看到这一点。
发布于 2017-03-14 10:43:55
试一下..。
#pulse::before, #pulse::after {
content: '';
position: absolute;
display: block;
width: 12.5px;
height: 33.3px;
background: #efefef;
animation: pulse 750ms infinite;
top: 50%;
transform: translateY(-50%);
}https://stackoverflow.com/questions/42776744
复制相似问题