html - 加载 gif 在页面中心对齐

标签 html css

我正在尝试制作一个正在加载的 gif 动图,使其位于手机页面的中央。 试过了

margin: 0 auto;

但我没有运气。

#bw-preloader, #bw-preloader:after {

    background:url(http://i.imgur.com/ImksiyD.gif) !important;
    background-repeat: no-repeat !important;
    border-radius: 0% !important;
    width: 256px !important;
    height: 256px !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    margin: -50px 0px 0px -50px; !important;
}

#bw-preloader {
border: 0px !important;
-webkit-transition: opacity 10s !important;

position: fixed !important;
top: 50% !important;
left: 50% !important;
margin: -50px 0px 0px -50px; !important;
}

@media only screen and (max-width: 500px) {
#bw-preloader {

position: fixed !important;
top: 50% !important;
left: 50% !important;
margin: -50px 0px 0px -50px; !important;
}
}

直播可以看到here

如果我遗漏了什么,有人可以检查一下吗?

也试过

position: absolute;

最佳答案

此示例代码可能会有所帮助。

HTML

<div class="image-container">
<p class="image-holder">
<img src="loading.gif" />
</p>
</div>

CSS

div.image-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    bottom: 0;
    background-color: #fff; 
    z-index: 999999;
    text-align: center;
}

.image-holder {
    position:absolute;
    left: 50%; 
    top: 50%;
    width: 30px;
    height: 30px;
}

.image-holder img 
{
    width: 100%;
    margin-left: -50%;
    margin-top: -50%;   
}

JS

$('div.image-container').delay(350).fadeOut('slow');

关于html - 加载 gif 在页面中心对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34455534/

相关文章:

javascript - 未捕获的类型错误 : Cannot read property 'value' of null Error for while changing value of INNER HTML

jquery - 使 Container.height = Right_Column.height

javascript - 将鼠标悬停在子菜单上时突出显示父菜单和子菜单

css - Bootstrap 多级菜单

javascript - 检查 DOM 元素和子元素是否包含任何文本 [JS 或 jQuery]

html - 如何使 Bootstrap 中的 <button> 看起来像导航选项卡中的普通链接?

html - CSS:td 是否可以从其标题推断样式,反之亦然?

html - NodeJs 在网络浏览器上显示

html - Firefox 中的 CSS 对 Angular 边框别名

html - 绝对定位的 DIV 在可滚动 DIV 中消失