我最近使用symfony工作,但仍然无法处理所有错误和问题。我无法修改树枝内任何东西的风格!如果我在css样式文件中使用css代码或者我使用div的样式属性它不起作用!!
这是样式表块:
<!-- CSS -->
{% block stylesheets %}
<link href={{asset("css/bootstrap.min.css")}} rel="stylesheet">
<link href={{asset("css/style2.css")}} rel="stylesheet">
<link href={{asset("css/font-awesome.min.css")}} rel="stylesheet">
{% endblock %}
这就是我要改变css的地方:
{% if users %}
<div id="users_table">
<table style="background-color: #f9f9f9;"
class="table table-responsive table-bordered">
<tr>
<th style="color: #1b6d85"> Matricule </th>
<th style="color: #1b6d85"> Mot de passe </th>
<th style="color: #1b6d85"> Etat </th>
<th style="color: #1b6d85"> Action </th>
</tr>
{% for user in users %}
{% set iduser = user.username %}
{% set id = user.username %}
<tr><td>{{ user.username }}</td><td>{{ user.password }}</td><td>{% if user.etat==1 %}actif
{% elseif user.etat==0%}inactif{% endif %}</td>
<td>
<button id="activer" class="btn btn-success btn-xs">
<a href="{{ path('act', {'iduser': iduser})}}" style="color: #ffffee;text-decoration:none">Activer</a>
</button>
<button id="desactiver" class="btn btn-danger btn-xs">
<a href="{{ path('desact', {'id': id})}}" style="color: #ffffee;text-decoration: none;">Désactiver</a>
</button>
</td></tr>
{% endfor %}
</table>
</div>
{% else %}
Aucun utilisateur n'a été trouvé.
{% endif %}
答案 0 :(得分:0)
1st - 如果每次都必须清除缓存,则更改View File(.html.twig) 对于开发者:
php bin/console cache:clear
为prod:
php bin/console cache:clear --env=prod
第二 - 检查浏览器中网页的源代码 - 资产是好地方(Best Practice Store your assets in the web/ directory.)
如果您使用bootstrap创建文件来使其适应TWIG:
# app\config\config.yml
# (...)
form:
resources:
- 'YourBundle:Form:form_theme.html.twig'
示例form_theme.html.twig:
# YourBundle\Resources\views\Form\form_theme.html.twig
{% spaceless %}
{% block form_start %}
{% set method = method|upper %}
{% if method in ["GET", "POST"] %}
{% set form_method = method %}
{% else %}
{% set form_method = "POST" %}
{% endif %}
{% set attr = attr|merge({'class': (attr.class|default('form-horizontal'))|trim }) %}
<form name="{{ form.vars.name }}" method="{{ form_method|lower }}" action="{{ action }}"{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
{% if form_method != method %}
<input type="hidden" name="_method" value="{{ method }}" />
{% endif %}
{% endspaceless %}
{% endblock form_start %}
{% block form_row %}
{% spaceless %}
<div class="form-group{{ errors|length > 0 ? ' has-error':'' }}">
{{ form_label(form) }}
<div class="col-sm-9">
{{ form_widget(form) }}
{{ form_errors(form) }}
</div>
</div>
{% endspaceless %}
{% endblock form_row %}
{% block form_label %}
{% spaceless %}
{% if label is not sameas(false) %}
{% if not compound %}
{% set label_attr = label_attr|merge({'for': id}) %}
{% endif %}
{% if required %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
{% endif %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' col-sm-3 control-label')|trim }) %}
{% if label is empty %}
{% set label = name|humanize %}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain) }}</label>
{% endif %}
{% endspaceless %}
{% endblock form_label %}
{% block form_widget_simple %}
{% spaceless %}
{% set type = type|default('text') %}
{% if type != 'file' %}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' form-control')|trim }) %}
{% endif %}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{% endspaceless %}
{% endblock form_widget_simple %}
{% block textarea_widget %}
{% spaceless %}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' form-control')|trim }) %}
<textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
{% endspaceless %}
{% endblock textarea_widget %}
{% block choice_widget_collapsed %}
{% spaceless %}
{% if required and empty_value is none and not empty_value_in_choices %}
{% set required = false %}
{% endif %}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' form-control')|trim }) %}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
{% if empty_value is not none %}
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
{% endif %}
{% if preferred_choices|length > 0 %}
{% set options = preferred_choices %}
{{ block('choice_widget_options') }}
{% if choices|length > 0 and separator is not none %}
<option disabled="disabled">{{ separator }}</option>
{% endif %}
{% endif %}
{% set options = choices %}
{{ block('choice_widget_options') }}
</select>
{% endspaceless %}
{% endblock choice_widget_collapsed %}
{% block choice_widget_expanded %}
{% spaceless %}
{% for child in form %}
<div class="checkbox">
<label>
{{ form_widget(child) }} {{ child.vars.label }}
</label>
</div>
{% endfor %}
{% endspaceless %}
{% endblock choice_widget_expanded %}
{% block form_errors %}
{% spaceless %}
{% for error in errors %}
<span class="help-block">{{ error.message }}</span>
{% endfor %}
{% endspaceless %}
{% endblock form_errors %}
{% block button_row %}
{% spaceless %}
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
{{ form_widget(form) }}
</div>
</div>
{% endspaceless %}
{% endblock button_row %}
{% block button_widget %}
{% spaceless %}
{% if label is empty %}
{% set label = name|humanize %}
{% endif %}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' btn')|trim }) %}
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ label|trans({}, translation_domain) }}</button>
{% endspaceless %}
{% endblock button_widget %}
{% block submit_widget %}
{% spaceless %}
{% set type = type|default('submit') %}
{% set attr = attr|merge({'class': (attr.class|default('btn-success'))|trim }) %}
{{ block('button_widget') }}
{% endspaceless %}
{% endblock submit_widget %}