首页 > 解决方案 > thymeaf 中的参数 css 宽度

问题描述

小米代码是:

<tr th:each="planificacion : ${planificaciones}"
                        th:onclick="'window.location.href = \'' + @{/planificacion/{idp}(idp=${planificacion.id})}+ '\''">

                        <td th:text="${planificacion.nombre}"></td>
                        <td>
                            <div th:if="${planificacion.completado}">
                                <span class="badge badge-pill badge-success"
                                    style="font-size: 80%; padding: 6px 18px;">Completo</span>
                            </div>
                            <div th:if="${not planificacion.completado}">
                                <span class="badge badge-pill badge-danger"
                                    style="font-size: 80%; padding: 6px 18px;">Incompleto</span>
                            </div>
                        </td>
                        <td>
                            **<div class="progress">
                                <div class="progress-bar progress-bar-success progress-bar-striped active"
                                    role="progressbar" aria-valuenow="0" aria-valuemin="0"
                                    aria-valuemax="100" style="width:0%">
                                    <span id="current-progress"></span>
                                </div>
                            </div>**
                        </td>
                        <td><a class="btn btn-danger"
                            th:href="@{/borrar_planificacion/{id}(id=${planificacion.id})}">
                                <i class="fas fa-trash-alt"></i>
                        </a></td>


                    </tr>
                </table>

我想用控制器变量 ${planificacion.porcentaje} 更改宽度值,但我不知道。

我该怎么做?

我读了这篇文章,但它对我不起作用。使用 thymeleaf 设置 CSS 样式属性

标签: htmlthymeleaf

解决方案


根据 Thymeleaf 文档 - 设置属性值

使用th:width="${planificacion.porcentaje}"th:attr="width=${planificacion.porcentaje}"


推荐阅读