K
K
kaidos2022-03-24 18:34:32
1C-Bitrix
kaidos, 2022-03-24 18:34:32

How to add styles to Bitrix header?

Added this code to header.php.

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
IncludeTemplateLangFile(__FILE__);
?>

<?php use Bitrix\Main\Page\Asset; ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <?php
        Asset::getInstance()->addString('<meta http-equiv="X-UA-Compatible" content="IE=edge">');
        Asset::getInstance()->addString('<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1">');
    ?>
    <title><?$APPLICATION->ShowTitle();?></title>
    <!--    Include CSS File    -->
    <?php
        Asset::getInstance()->addCss(SITE_TEMPLATE_PATH . "/fonts/fonts.css");
        Asset::getInstance()->addCss(SITE_TEMPLATE_PATH . "/css/style.css");
        Asset::getInstance()->addCss(SITE_TEMPLATE_PATH . "/libs/owl.carousel.min.css");
        Asset::getInstance()->addCss(SITE_TEMPLATE_PATH . "/libs/owl.theme.default.min.css");
        Asset::getInstance()->addCss(SITE_TEMPLATE_PATH . "/libs/modal/style.css");
    ?>


Placed all css/fonts in the template folder, but the styles are not included.
The page code looks like this:
623c8fca8cdcf979622373.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kaidos, 2022-03-24
@kaidos

<?php 
    use Bitrix\Main\Page\Asset; 
    $APPLICATION->ShowHead(); // нужно было добавить
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question