加了thymeleaf的th:标签后div无法显示在同一行

I-Rokkk 2020-05-16 02:09:16
想用th:switch来显示指定html内容。有没有什么其他方法可以做到这种效果。th:标签写在div里,div会自动换行。用了display:inline-block等方法也不行。原因应该就是多了一层div。
具体问题:
使用th:each后每个col都独占一行,不能一行多个显示
<div class="row filterable-content">
<div th:each="item, itemStat: ${xxxx_list}" th:switch="${item.xxxx_area}">
<!-- col start -->
<div th:case="1" class="col-sm-6 col-xl-3 filter-item 1">
xxx
</div>
<!-- end col -->
</div>
</div>

原来这样是正常显示的:
<div class="row filterable-content">
<!-- col start -->
<div class="col-sm-6 col-xl-3 filter-item 1">
xxx
</div>
<!-- end col -->
</div>

其他:用了bootstrap的框架。是一个springboot项目。
...全文
539 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
I-Rokkk 2020-05-16
  • 打赏
  • 举报
回复
引用 2 楼 nian_cj 的回复:
<div class="row filterable-content" th:each="item, itemStat: ${xxxx_list}" th:switch="${item.xxxx_area}"> <!-- col start --> <div th:case="1" class="col-sm-6 col-xl-3 filter-item 1"> xxx </div> <!-- end col --> </div>
这样是不行的,跟外面的div没关系吧。
_念_ 2020-05-16
  • 打赏
  • 举报
回复
<div class="row filterable-content" th:each="item, itemStat: ${xxxx_list}" th:switch="${item.xxxx_area}"> <!-- col start --> <div th:case="1" class="col-sm-6 col-xl-3 filter-item 1"> xxx </div> <!-- end col --> </div>

61,111

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧