Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wp-statistics domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/s/serjpozw/wp-prog.ru/public_html/wp-includes/functions.php on line 6114 Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the cyr2lat domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/s/serjpozw/wp-prog.ru/public_html/wp-includes/functions.php on line 6114 Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the essential-addons-for-elementor-lite domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/s/serjpozw/wp-prog.ru/public_html/wp-includes/functions.php on line 6114 Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the translatepress-multilingual domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/s/serjpozw/wp-prog.ru/public_html/wp-includes/functions.php on line 6114 Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/s/serjpozw/wp-prog.ru/public_html/wp-includes/functions.php on line 6114 Как сделать прелоадер для части сайта - WP-prog

WP-prog

Как сделать прелоадер для части сайта

Если сайт грузится слишком долго, то разработчики часто используют прелоадеры. Обычно они позволяют скрывать всю страницу до ее полной загрузки. А как быть, если нам нужно использовать прелоадер не на всей странице целиком, а только на каком-то определённом блоке. В этой статье описано моё решение этой задачи.

HTML-код
				
					<section id="block">
    <div id="content">
        <h1>Здесь Ваш контент</h1>
        <p>Как можно сделать прелоадер на отдельный блок, а не на сайт целиком</p>
        <button>Отлично!</button>
        <div id="preloader">
            <span style="padding-top:120px;">Загрузка...</span>
        </div>
    </div>
</section>
				
			
СSS
				
					#content {
        position: relative;
        text-align: center;
        height: auto;
        width: 350px;
        border: 1px solid green;
        padding: 20px 0;
    }

    #preloader {
        position: absolute;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        background-image: url('https://wp-prog.ru/wp-content/uploads/2021/04/Rainbow.gif');
        background-position: center;
        background-repeat: no-repeat;
        background-color: #fff;
    }

    #block {
        width: 100%;
        height: 600px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
				
			
jQuery
				
					jQuery('#preloader').delay(1000).fadeOut(2500);
				
			

Ну и конечно же, не забываем предварительно подключить jQuery.

Если у Вас есть какие-либо вопросы, оставьте свой комментарий:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *