2016-07-28 32 views
0

ホバー上に暗いオーバーレイがある画像があります。これはうまくいくが、バックグラウンドをスライドさせたい。私は、トランジションやバックグラウンドのショーでそれをやってみましたが、中にスライドしない。 これは私のコード背景色のCSS遷移

HTML

<div class="products_overlay"> 
    <a href="<?php echo $_product->getProductUrl() ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(200); ?>" class="hover_test" /></a> 

    <ul> 
     <li> 
      <?php echo $_product->getData(‘price’); ?></li> 
     <li> 
      <?php echo $_product->getAttributeText(‘desc); ?></li> 
     <li> 
      <?php echo $_product->getAttributeText('country'); ?></li> 
    </ul> 

</div> 

CSS

.hover_test { 
     position: relative; 
    } 
    .products_overlay:hover:after { 
     content: ""; 
     position: absolute; 
     top: 0; 
     left: 0; 
     bottom: 0; 
     right: 0; 
     background-color: rgba(0, 0, 0, 0.8); 
     -webkit-transition: background-color .5s ease-in; 
     -moz-transition: background-color .5s ease-in; 
     -o-transition: background-color .5s ease-in; 
     -ms-transition: background-color .5s ease-in; 
     transition: background-color .5s ease-in; 
    } 

どのように上の任意の提案ですこれを行う?

+0

あなたは色付きのオーバーレイがあなたのdiv /画像上にスライドさせたいのですが意味するのですか?私は 'hover_test'(CSS内)と' hover_text'(HTML内)を推測しているのはちょうどタイプミスですか? – webeno

+0

はい、正確です。しかし、色付けされたオーバーレイの上に何かのテキストもあります。ええ、そのhover_textクラスを取り除くことを忘れました – MariaL

+0

あなたは唯一の背景色を変えて、別のトランジションを追加する必要があります。 – DirtyRedz

答えて

0

これを試してみてください:

.hover_test {position:relative;} 

.products_overlay:after { 
    content:""; 
    position:absolute; top:0; 
    left:0; 
    bottom:0; 
    right:0; 
    background: rgba(0, 0, 0, 0.8); 
    overflow: hidden; 
    -webkit-transition: all 0.5s; 
    -moz-transition: all 0.5s; 
    -o-transition: all 0.5s; 
    transition: all 0.5s; 
    width:0; 
    } 

.products_overlay:hover:after{ 
    width:100%; 
} 
+0

華麗な、ありがとう! – MariaL

+0

大歓迎:) –