简体   繁体   中英

Bootstrap template in symfony

I bought bootstrap template and try to implement it to my symfony project, but it does not works. I included css and js like this:

<link href="{{ asset('/css/bootstrap.min.css') }}" rel="stylesheet">

What i did wrong?

Put your bootstrap assets folders (css, js, images...) in your web folder. Next use this code:

<link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet">

in your twig template.

Go into your website, locally or not, and press CTRL-i. Here, browse the DOM of your page and look if the stylesheet path is valid or not. This will be the first step to find where the issue is coming from.

It's important in Symfony to use blocks and one folder assets inside of folder web.

Example:

{% block stylesheets %}
        <link href="{{ asset('assets/bootstrap/css/bootstrap.min.css') }}" type="text/css" rel="stylesheet" />
        <link href="{{ asset('assets/css/bootstrap.cosmo.min.css') }}" type="text/css" rel="stylesheet" />
        <link href="{{ asset('assets/css/styles.css') }}" type="text/css" rel="stylesheet" />
{% endblock %}

Regards

问题出在XAMPP中,已交换到VertigoServ,并且现在可以使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM