css - 如何在多个元素上应用 css hover

标签 css hover

您好,我正在研究仅使用 CSS 的简单悬停。我很好奇是否可以将一个悬停应用于多个 html 元素。这是我的例子:

.work-cart{
    z-index: 4;
  position: absolute;
    width: 250px;
    height: 300px;
    left: 200px;
    opacity: 0;
    background: #fff;
    padding-right: 45px;
    padding-left: 45px;
    padding-bottom: 30px;
    padding-top: 150px;
    text-align: right;
    bottom: 0;
    -webkit-transition: all 0.8s ease;
    -moz-transition: all 0.8s ease;
    -o-transition: all: 0.8s ease;
    transitions: all 0.8s ease;
}
.f:hover > .work-cart{
   left: 220px;
    opacity: 1;
}
.g:hover > .work-cart{
   left: 220px;
    opacity: 1;
}
.h:hover > .work-cart{
   left: 220px;
    opacity: 1;
}

是否有任何选项可以同时为 .f .g 和 .h 分配悬停?

最佳答案

你可以试试

.f:hover > .work-cart, .g:hover > .work-cart, .h:hover > .work-cart{
   left: 220px;
   opacity: 1;
}

关于css - 如何在多个元素上应用 css hover,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33593725/

相关文章:

html - 悬停图像

javascript - Word 悬停时弹出窗口

css - 将鼠标悬停在波浪线上

javascript - 似乎无法让我的 jQuery 工作

javascript - 超时后无法删除新添加的 HTML 元素

html - Bootstrap 3.3.7 下拉只有一个链接可点击

javascript - 一行中的相同 slider

html - 如何在无序列表中旋转用作列表类型的图像

css - 如何使用悬停按钮更改图标不透明度

css - 鼠标悬停在图像上会更改文本链接颜色