簡體   English   中英

Bootstrap 3無法在Symfony3中運行

[英]Bootstrap 3 not working in Symfony3

我剛剛開始學習Symfony3,我正在嘗試使用bootstrap3來構建我的表單。 根據文檔bootstrap_3_layout.html.twig是內置的,可以通過更改config.yml的Twig設置來全局激活:

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form_themes: 
        - "bootstrap_3_layout.html.twig"

當我重新加載頁面時,頁面加載沒有CSS,twig文件和頁面源如下:

{# app/Resources/views/experiment/new.html.twig #}

{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}


<form name="form" method="post">
<div id="form"><div class="form-group"><label class="control-label required" for="form_title">Title</label><input type="text" id="form_title" name="form[title]" required="required" class="form-control" /></div><div class="form-group"><button type="submit" id="form_save" name="form[save]" class="btn-default btn">Create Task</button></div><input type="hidden" id="form__token" name="form[_token]" class="form-control" value="O7tN2AUjyLByEz2tkNf675jqixxjev0p4ivzs5Bn4VA" /></div>
</form>

這表明bootstrap3類已正確注入。 該網站本身如下:

在此輸入圖像描述

我錯過了哪些步驟讓CSS正常工作?

您仍然需要將引導文件CSS和JS添加到您的應用程序和模板中。 表單主題僅確保標記根據引導程序很好地形成。

作為一種替代方式,您可以包含捆綁包

https://github.com/phiamo/MopaBootstrapBundle

進入你的項目並獲取Bootstrap文件(sass / less)進入你的項目。

該頁面上還提供了有關安裝的文檔。 我正在使用自編寫的集成,它使用非常類似的方法。

優點是,您可以將自定義sass包含到項目中並編譯為包含在模板頭中的單個css文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM