【发布时间】:2016-10-29 17:31:03
【问题描述】:
我只想制作一个位于页面中间的预加载器。
要求:
- 位置:固定;
- 以 X 轴为中心
它只是一个在 body 中带有类 'preloader' 的 div。 Body 是这个 div 的直接父级,中间没有其他包装器。
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 45%;
left: 50%;
width: 60px;
height: 60px;
-ms-transform: translateX(100px); /*100px just to test if it moved at all, initially had -50%, see list below*/
-webkit-transform: translateX(100px);
transform: translateX(100px);
//=====rest is just animation and aesthetics======
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
我已经完成了:
- 显示:块;
- 显示:内联块;
- translateX(-50%);
- translateX(30px);
- 翻译(-50%, 0);
- 翻译(30px, 0);
- 翻译(-50%, -50%);
- 重新排列变换.. 哈哈
- 起飞-o & -mos
- margin: 0 auto(在我不需要固定时使用 position: relative)
【问题讨论】:
-
将您的代码添加到 jsfiddle 并提供链接。