javascript - 如何在 vaadin-grid 中实现行悬停样式?

标签 javascript web-component polymer-2.x vaadin-grid

我试图在 vaadin-grid 中实现行悬停样式,将鼠标悬停在行上时,其样式会发生变化。 我的代码是

<dom-module id="grid-styles" theme-for="vaadin-grid">
    <template>
        <style>
             [part~="body-cell"] :hover {
                 background-color: beige;
            }   
        </style>
    </template>
</dom-module>

但是这段代码不起作用。有人可以帮忙吗?也没有关于它的文档。

PS。在以前的版本中,这是使用 --vaadin-grid-body-row-hover-cell 完成的。

编辑:我有用户以下代码,但它仅影响单元格,而不影响整个行

[part~="cell"]:hover ::slotted(vaadin-grid-cell-content) {
  background-color: beige;
}

最佳答案

这就是我的做法(有些样式有更深、更具体的选择器):

<dom-module id="grid-styles" theme-for="vaadin-grid">
  <template>
      <style>
        :host [part~="row"]:hover [part~="body-cell"]{
          background-color: rgba(0, 55, 108, 0.12);
        } 

        :host [part~="body-cell"] ::slotted(vaadin-grid-cell-content){
          cursor: pointer;
        }
      </style>
  </template>
</dom-module> 

关于javascript - 如何在 vaadin-grid 中实现行悬停样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53865048/

相关文章:

php - 如何使用带有自定义对话框的 TinyMCE 自定义按钮来添加内容?

javascript - 重用导入的 Web 组件模板

html - Polymer 2.x 单元测试将可选内容传递给 fixture 以绑定(bind)到目标属性

javascript - 在 JS/Angular 中过滤嵌套数组无法正常工作

javascript 阻止点击

polymer - Web 组件、Polymer 和 SystemJS

caching - 灯塔和 polymer : start_url in manifest is not cached by Service Worker

polymer-2.x - Polymer-cli - 获取 "Can’ t 查找变量 : babelHelpers"when I set compile to true

javascript - 使用 JSONP 时如何捕获 jQuery $.getJSON(或数据类型设置为 'jsonp' 的 $.ajax)错误?

angular - 将组件用作自定义元素和 Angular 组件