Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading gif align in the center of the page

Tags:

html

css

I am trying to make a loading gif to be on the center of the page also in mobiles. Have tried

margin: 0 auto;

but i had no luck.

#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;
}
}

You can see it live here

Could someone check it out if im missing something?

Also have tried

position: absolute;

1 Answers

This example code might help.

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');
like image 102
Heroselohim Avatar answered Nov 01 '25 10:11

Heroselohim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!