2016-04-09 11 views
1

私は比較的新しいコーディングで、1つのイメージが別のイメージにフェードし、そのイメージの上にテキストがあるようにしようとしています。どのようにイメージをフェードアウトし、テキストを持つ別のイメージをフェードさせるのでしょうか?

私はTumblrを使用しているので、PHP-5専用のMVCです。私はかなり確信しています。 そして、ここでは、私がこれまで持っているものです。

<style> 
 
    #imagefade { 
 
    background-image: url('http://i65.tinypic.com/107kqbq.jpg'); 
 
    position: absolute; 
 
    } 
 
    #imagefade img { 
 
    -webkit-transition: all ease 1.5s; 
 
    -moz-transition: all ease 1.5s; 
 
    -o-transition: all ease 1.5s; 
 
    -ms-transition: all ease 1.5s; 
 
    transition: all ease 1.5s; 
 
    } 
 
    #imagefade img:hover { 
 
    opacity: 0; 
 
    } 
 
    #text { 
 
    position: center; 
 
    } 
 
    .image { 
 
    position: relative; 
 
    } 
 
    p { 
 
    position: absolute; 
 
    top: 200px; 
 
    left: 38px; 
 
    width: 100%; 
 
    font-family: arial; 
 
    font-size: 12px; 
 
    color: white; 
 
    } 
 
</style> 
 

 
<div id="imagefade"> 
 
    <img src="http://i68.tinypic.com/2i9s4eb.jpg" /> 
 
    <p>text heading here</p> 
 
</div>

+0

のStackOverflowへようこそ! a)使用している言語を説明し(そしてタグを使用する)、b)これまでに試したことを示すならば、答えを得る可能性がはるかに高い。 – elhefe

+0

ちょうど親切なヒント、このページを読むことができます:[How-To-Ask Guide](https://stackoverflow.com/help/how-to-ask)可能な限り簡単に答えることができます。あなたが抱えている問題を修正するためにあなたがした努力と、それらの修正を試みたときに何が起こったのかを必ず含めてください。ショーコードとエラーメッセージも忘れないでください! –

答えて

1

私はあなたが何をしたいから、それが正しいなった場合は、これを行う最も簡単な方法は、これを達成するために:hoverposition: absolute;opacityを使用しています。ポジショニングでは、レイヤーが互いに重なり合うように設定されます(例のように)。

下記の私の例を参照してください。

.container { 
 
    background: lightblue; 
 
    position: relative; 
 
    width: 500px; 
 
    height: 300px; 
 
} 
 

 
.box { 
 
    background-image: url('https://i.imgur.com/AzeiaRY.jpg'); 
 
    background-position: center; 
 
    position: absolute; /* Setting the boxes on top of each other */ 
 
    top: 0; 
 
    left: 0; 
 
    right: 0; 
 
    bottom: 0; 
 
    display: block; 
 
    transition: opacity .4s ease-in-out; /* Transition the opacity for the :hover */ 
 
} 
 

 
.image-2 { 
 
    background-position: bottom right; 
 
    opacity: 0; 
 
} 
 

 
.image-1:hover .image-2 { 
 
    opacity: 1; 
 
} 
 

 

 
/* Pure for styling below */ 
 

 
.box-text { 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
    color: #fff; 
 
    padding: 10px; 
 
    background: rgba(0, 0, 0, .8); 
 
    width: 40%; 
 
    height: 100%; 
 
    box-sizing: border-box; 
 
}
<div class="container"> 
 

 
    <div class="box image-1"> 
 

 
    <div class="box image-2"> 
 

 
     <div class="box-text"> 
 

 
     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias, mollitia. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Enim ipsa maxime modi velit similique maiores, porro voluptate? Molestias ratione natus consequatur libero eaque 
 
      pariatur optio quisquam minima. Nemo quis, odit. 
 
     </p> 
 

 
     </div> 
 

 
    </div> 
 

 
    </div> 
 
</div>

+0

はい!どうもありがとうございます! – Brooke

関連する問題