javascript - 如何通过悬停调用类/id

标签 javascript jquery html css

我有一个小型电子商务网站,其产品 GridView 包含:

.product-image
.product-price
.product-name

在主产品页面中,它包含与上面相同的类,加上:

.product-discount

我试图在 GridView 上执行的操作是当 .product-image 悬停在上方时显示 .product-discount 标记。

我只想知道如何悬停类标签。我尝试过:

.product-image:hover { something that would call the .product-discount; }

enter image description here

最佳答案

伪类不一定是尾随部分。所以这是有效的并且应该有效:

.product-image .product-discount { visibility:hidden; } /* make sure it takes up space (for whatever reason) */
.product-image:hover .product-discount{ visibility:visible; }

关于javascript - 如何通过悬停调用类/id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12766613/

相关文章:

javascript - 使用谷歌地图 javascript api 绘制使用坐标所采取的路径

javascript - Angular 2 的 IE 10/11 和 Edge Shim

javascript - 在甘特图 d3.js 顶部绘制多条线

javascript - jQuery 将一个 div 包裹在一个巨大的 HTML block 中

javascript - jQuery验证textarea验证

javascript - 单击li元素后如何切换ul的id?

html - 不将鼠标悬停在下拉式菜单上时,使下拉式菜单保持不变

html - CSS - 在没有重叠/绝对定位的情况下将元素对齐到居中的 div 的右侧?

html - CSS 2 位置 :Fixed Elements weird behaviour

javascript - 我可以在保存之前使用 webpack Hook 来修改文件输出吗?