显示一个元素,它不是具有纯css的锚点的子元素

时间:2013-01-27 21:11:04

标签: html css

我想触发元素在悬停

上显示隐藏元素

HTML

<div class="contents">
   <aside>
     <section class="tumb">
       <a class="placeHoldTumb" href="#"><img src="http://placehold.it/100x100">
       <a class="placeHoldTumb" href="#"><img src="http://placehold.it/100x100">
     </section>
   </aside>
   <div class="hidden">
      <a href="#" class="one" ><img src="http://placehold.it/1000x1000/bada55" width="500px" ></a>
      <a href="#" class="two" ><img src="http://placehold.it/1000x1000/bada55" width="500px" ></a>
   </div>
   <a href="#" class="background" ><img src="http://placehold.it/1000x1000/000000/bada55" width="500px" /></a>
</div><!-- end contents -->

CSS

aside  {
  z-index: 100;
  background: rgba(0, 182, 173, 0.9); 
  width: 230px; 
  position: absolute; }
aside .tumb img { 
  margin: 5px; position: relative; }
.contents img {
  position: absolute; }
.hidden img {  opacity: 0; }

.tumb a:hover ~ .hidden img {
  opacity: 1;
  filter:alpha(opacity=100); /*For IE8*/ }

演示:http://codepen.io/mvaneijgen/pen/ELBAg

1 个答案:

答案 0 :(得分:0)

在你的代码中尝试以下CSS ......它会起作用

.hidden{ 
opacity:0;
    filter:alpha(opacity=0); 
}
.contents:hover .hidden{
opacity: 1;
    filter:alpha(opacity=100);
}

我在小提琴中尝试过您的代码...请参阅此链接:http://jsfiddle.net/NUBkp/14/