You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vaadin 23 Grid CSS样式不生效,请求正确语法指导

Vaadin 23 Grid CSS样式修正方案

问题原因

你给Grid组件添加了styled类,但当前CSS选择器错误地将目标指向了内部vaadin-grid-cell-content元素的styled类,而非带styled类的Grid下的单元格内容,导致样式无法生效。

正确的CSS语法

.styled [part~='cell'] ::slotted(vaadin-grid-cell-content) {
    white-space: break-spaces;
}

说明

  • .styled:选中添加了该类的Grid组件
  • [part~='cell']:定位到Grid内部的单元格部分
  • ::slotted(vaadin-grid-cell-content):选中单元格插槽内的内容元素

通过上述选择器,就能正确为带有styled类的Grid的所有单元格内容应用white-space: break-spaces样式。

内容的提问来源于stack exchange,提问作者Vishu Dhanawade

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 18:16:38