Twig 文件 - 使所有字段显示在单列而不是 2 列中
Twig file - Make all the fields appear in a single column instead of 2 columns
我有一个视图的树枝模板,其中的字段显示在 2 列上。有没有办法让所有字段出现在同一列中?
树枝代码:
{% set index = 0 %}
<div class='row'>
<div class="panel panel-default">
<div class="panel-body">
{% for key, field in fields -%}
{% if index == 0 or index == 5 %}
<div class='col-md-6'>
{% endif %}
<span {{ field.label_attributes }}>{{ field.label }}{{ field.label_suffix }}</span>
<a href="#" data-toggle="tooltip" data-placement="right" title="{{ tooltips[key] }}">
<span {{ field.element_attributes }}>{{ field.content }}</span><br/>
</a>
{% if index + 1 == fields | length %}
<a href=''>Test link</a>
{% endif %}
{% if index == 4 or index + 1 == fields | length %}
</div>
{% endif %}
{% set index = index + 1 %}
{%- endfor %}
</div>
</div>
</div>
当前输出:
如何让所有字段都出现在一列中?
你能不能使用 flex-direction: column.. 将 class 包裹在 css 中,例如:
.panel-body{
display:flex
flex-direction: column
}
非常简单的修复。我从面板中删除了 class,它将所有字段都放在一个列中。
<div class='col-md-6'> changed to just <div> tag
我有一个视图的树枝模板,其中的字段显示在 2 列上。有没有办法让所有字段出现在同一列中?
树枝代码:
{% set index = 0 %}
<div class='row'>
<div class="panel panel-default">
<div class="panel-body">
{% for key, field in fields -%}
{% if index == 0 or index == 5 %}
<div class='col-md-6'>
{% endif %}
<span {{ field.label_attributes }}>{{ field.label }}{{ field.label_suffix }}</span>
<a href="#" data-toggle="tooltip" data-placement="right" title="{{ tooltips[key] }}">
<span {{ field.element_attributes }}>{{ field.content }}</span><br/>
</a>
{% if index + 1 == fields | length %}
<a href=''>Test link</a>
{% endif %}
{% if index == 4 or index + 1 == fields | length %}
</div>
{% endif %}
{% set index = index + 1 %}
{%- endfor %}
</div>
</div>
</div>
当前输出:
你能不能使用 flex-direction: column.. 将 class 包裹在 css 中,例如:
.panel-body{
display:flex
flex-direction: column
}
非常简单的修复。我从面板中删除了 class,它将所有字段都放在一个列中。
<div class='col-md-6'> changed to just <div> tag