2016-04-16 28 views
0

を伸ばします。私は効果があるが、私の初期のイメージは伸びている。私は背景画像のサイズがわからない、ユーザーがホバリングしているときに画像が少しズームしたいだけです。ズーム効果CSS3私はこの効果を作成したい私のイメージ

.highlight{ 
    background-size: 100% 100%; 
    -moz-transition: background-size 3s ease, background-color 3s ease; 
    -webkit-transition: background-size 3s ease, background-color 3s ease; 
    transition: background-size 3s ease, background-color 3s ease; 
} 

.highlight:hover{ 
    background-size: 120% 120%; 
    background-color:rgba(0,0,0,0); 
    -moz-transition: background-size 3s ease, background-color 3s ease; 
    -webkit-transition: background-size 3s ease, background-color 3s ease; 
    transition: background-size 3s ease, background-color 3s ease; 
} 

.highlight:hover:before{ 
    content: ""; 
    display: inline; 
    width: 100%; 
    height: 100%; 
    background-color:rgba(0,0,0,0.7); 
    -moz-transition: background-size 3s ease, background-color 3s ease; 
    -webkit-transition: background-size 3s ease, background-color 3s ease; 
    transition: background-size 3s ease, background-color 3s ease; 
} 

<div class="col-xs-12 col-sm-12 col-md-6"> 
<div class="highlight" style="background-image:url(image-url)"> 
    <div class="content"> 
     <h3>Text</h3> 
     <p class="large">More text text text</a> 
    </div> 
</div> 
</div> 
<div class="col-xs-12 col-sm-12 col-md-6"> 
<div class="highlight" style="background-image:url(image-url2)"> 
    <div class="content"> 
     <h3>Text2</h3> 
     <p class="large">More text text text2</a> 
    </div> 
</div> 
</div> 

enter image description here

答えて

1

これはあなたが探して何ですか?

.highlight{ 
 
    position: relative; 
 
    height: 300px; 
 
    background-size: 100%; 
 
    background-position: center top; 
 
    -moz-transition: background-size 3s ease; 
 
    -webkit-transition: background-size 3s ease; 
 
    transition: background-size 3s ease; 
 
} 
 
.highlight:hover{ 
 
    background-size: 120%; 
 
    background-color:rgba(0,0,0,0); 
 
    -moz-transition: background-size 3s ease; 
 
    -webkit-transition: background-size 3s ease; 
 
    transition: background-size 3s ease; 
 
} 
 

 
.highlight:before{ 
 
    content: ' '; 
 
    position: absolute; 
 
    left: 0; top: 0; 
 
    right: 0; bottom: 0; 
 
    background-color:rgba(0,0,0,0); 
 
    -moz-transition: background-color 3s ease; 
 
    -webkit-transition: background-color 3s ease; 
 
    transition: background-color 3s ease; 
 
} 
 
.highlight:hover:before{ 
 
    background-color:rgba(0,0,0,0.7); 
 
    -moz-transition: background-color 3s ease; 
 
    -webkit-transition: background-color 3s ease; 
 
    transition: background-color 3s ease; 
 
}
<div class="highlight" style="background-image:url(http://lorempixel.com/1100/700/nature/2/)"> 
 
    <div class="content"> 
 
     <h3>Text</h3> 
 
     <p class="large">More text text text</p> 
 
    </div> 
 
</div>

+0

ほぼ完璧! 私はこの効果を2つの画像で一緒にして、ページ幅の50%をシャドウします。今、「余白」が上下に表示されます。私はあなたの例を見ることができるように私のポストに画像を追加します。私は問題は、hightligh divは "col-xs-12 col-sm-12 col-md-6" divで囲まれているということです。 – Genaut

+0

@ user1422434そのマージンは 'h3'に属している可能性が高いので、CSSに' h3 {margin:0} 'を追加すると、それは消えてしまいます。そうでない場合は、コードスニペットを投稿する必要があります。これにより、他に何ができるかがわかります。 – LGSon

+0

問題は、使用している画像が2200x1400で、画像が600 * 400おそらくかわいいですか? – Genaut

関連する問題