悬停框并在顶部更改三角形

时间:2015-07-18 21:44:12

标签: html css css3

我的盒子上面有一个三角形。两者的颜色相同,但悬停在盒子上时,三角形的颜色保持不变。

如何更改三角形的颜色? [在此输入链接描述] [1]

.vw-post-box-read-more {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    line-height: 1em;
    padding: 20px 15px 15px 15px;
    -webkit-transition: all 0.2s ease-out;
    -moz-transition: all 0.2s ease-out;
    transition: all 0.2s ease-out;
    background-color: #393939;
    /*background-color: rgba(255, 255, 255, 0.15);*/
}
.vw-post-box-read-more .triangle {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 10px 10px 10px;
    -webkit-transition: all 0.2s ease-out;
    -moz-transition: all 0.2s ease-out;
    transition: all 0.2s ease-out;
    border-color: transparent transparent #393939 transparent;
}
<div class="triangle"></div>
<a class="vw-post-box-read-more" href="">
    <span>Read More</span>
    <i class="vw-icon icon-iconic-right-circle"></i>
</a>
编辑:Sebastian Olsen帮助了我,谢谢你

1 个答案:

答案 0 :(得分:0)

您正在尝试将三角形设置为vw-post-box-read-more

的子项

试试这段代码:

.vw-post-box-read-more {
  line-height: 1em;
  padding: 20px 15px 15px 15px;
  -webkit-transition: all 0.2s ease-out;
  -moz-transition: all 0.2s ease-out;
  transition: all 0.2s ease-out;
  background-color: #393939;
  /*background-color: rgba(255, 255, 255, 0.15);*/
}
.triangle {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 10px 10px 10px;
  -webkit-transition: all 0.2s ease-out;
  -moz-transition: all 0.2s ease-out;
  transition: all 0.2s ease-out;
  border-color: transparent transparent #393939 transparent;
  margin-bottom: 20px;
}
.hover-box:hover > .vw-post-box-read-more {
  background-color: red;
}

.hover-box:hover > .triangle {
  border-color: transparent transparent red transparent;
}
<div class="hover-box">
<div class="triangle"></div>
<a class="vw-post-box-read-more" href="">
  <span>Read More</span>
  <i class="vw-icon icon-iconic-right-circle"></i>
</a>
  </div>