我有一组具有不同rgba背景颜色但相同alpha值的<a>
标签。是否可能编写一个单一的css样式,仅更改rgba属性的不透明度?
以下是代码的快速示例:
<a href="#"><img src="" /><div class="brown">Link 1</div></a>
<a href="#"><img src="" /><div class="green">Link 2</div></a>
还有样式
a {display: block; position: relative}
.brown {position: absolute; bottom: 0; background-color: rgba(118,76,41,.8);}
.green {position: absolute; bottom: 0; background-color: rgba(51,91,11,.8);}
我想做的是编写一个单一的样式,当鼠标悬停在标签上时更改不透明度,但保持颜色不变。像这样
a:hover .green, a:hover .brown {background-color: rgba(inherit,inherit,inherit,1);}
div
元素在a
元素里面是干什么的? - BoltClocka
元素。 - mercatora
标签,而不是一个包围着img
和另一个包围着文本的标签。HTML 5支持它是一个很好的奖励。 - Fireflight