html - 圆形容器的悬停效果

标签 html css rollover-effect

我有一个圆圈,上面有悬停效果,下面有一些文字。现在我想要实现的是,当您滑过整个圆形容器而不仅仅是圆形本身时,触发悬停效果。

演示 http://jsfiddle.net/kL0vxrxL/

.icon-circle-box {
  text-align: center;
  margin: 0 auto 130px;
}
.icon-circle {
  display: inline-block;
  font-size: 42px;
  cursor: pointer;
  margin: 0 0 28px;
  width: 100px;
  height: 100px;
  line-height: 100px;
  border-radius: 50%;
  text-align: center;
  position: relative;
  z-index: 1;
  color: #fff;
}
.icon-circle-box p {
  margin-top: 13px;
}
.icon-circle:after {
  pointer-events: none;
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  content: '';
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
}
.icon-circle:before {
  font-family: 'lineicons';
  speak: none;
  font-size: 42px;
  line-height: 100px;
  display: block;
}
.circle-effect .icon-circle {
  color: #000;
  box-shadow: 0 0 0 2px #000;
  -webkit-transition: color 0.3s;
  -moz-transition: color 0.3s;
  transition: color 0.3s;
}
.circle-effect .icon-circle:after {
  top: -2px;
  left: -2px;
  padding: 2px;
  z-index: -1;
  background: #000;
  opacity: 0;
  filter: alpha(opacity=0);
  -webkit-transition: -webkit-transform 0.2s, opacity 0.2s;
  -moz-transition: -moz-transform 0.2s, opacity 0.2s;
  transition: transform 0.2s, opacity 0.2s;
}
.icon-circle:hover {
  color: #fff;
}
.icon-circle:hover:after {
  -webkit-transform: scale(0.85);
  -moz-transform: scale(0.85);
  -ms-transform: scale(0.85);
  transform: scale(0.85);
  opacity: 1;
  filter: alpha(opacity=100);
}
<div class="icon-circle-box circle-effect">
  <a href="#" class="icon-circle"></a>
  <p>Donec id elit non mi porta gravida at eget metus.</p>
</div>

最佳答案

I'm trying to achieve is to trigger that hover effect when you rollover the entire circle container and not only the circle itself.

然后您可以将 :hover 伪类添加到父元素 .icon-circle-box

Updated Example

.icon-circle-box:hover .icon-circle:after {
    -webkit-transform: scale(0.85);
    -moz-transform: scale(0.85);
    -ms-transform: scale(0.85);
    transform: scale(0.85);
    opacity: 1;
    filter: alpha(opacity=100);
}

关于html - 圆形容器的悬停效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28746573/

相关文章:

jquery - 如何为这个社交图标获得相同的jquery悬停效果?

jquery - JQuery Hilight 插件有替代品吗?

html - 如何更改打开新窗口的方法

javascript - 在 <body> 中打开其他 URL 使用 hash # without leave URL

html - 使用 CSS 定位 Wordpress 标题

html - 无法弄清楚如何在 float 的 div 旁边放置任何东西

html - 如何使 float 中的文本居中?

css - 相对路径 - 绝对路径不起作用?

html - 有没有办法为 Bootstrap 网格执行 1.5、8.5 和 2?