我創建了2個框,在懸停時,褪色爲紅色,但我希望文本保持完全白色並且不會與背景/圖像褪色。我在編碼方面不是很先進,但如果可能的話,任何幫助都會與現場演示一起欣賞?隨着背景顏色從褪色中停止文本
CSS
.image {
position:relative;
width:400px;
height:200px;
background-color:#555555;
color: #ffffff;
}
.image img {
width:50%;
vertical-align:top;
color: #ffffff;
}
.image:after, .image:before {
position:absolute;
background-color:rgba (255,0,0,1);
opacity:0;
transition: 0.5s ease;
-webkit-transition: 0.5s ease;
color: #ffffff;
}
.image:after {
content:'\A';
width:100%; height:100%;
top:0; left:0;
background-color:rgba(255,0,0,0.75);
color:#ffffff;
}
.image:before {
width:50%;
color:#fff;
z-index:1;
bottom:0;
padding:4px 10px;
text-align:center;
background-color:red;
box-sizing:border-box;
-moz-box-sizing:border-box;
color: rgba(255,255,255,0);
}
.image:hover:after, .image:hover:before {
opacity:1;
}
.text {
padding-left:210px;
padding-right:10px;
margin-top:-190px;
color:rgba(255,255,255,10);
font-family:Arial;
font-size:15px;
opacity: 1;
}
HTML
<div class="image">
<img src="http://www.newyorker.com/online/blogs/photobooth/NASAEarth-01.jpg" alt="" />
<div class="text">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.</p>
</div>
</div>
<hr>
<div class="image">
<img src="http://www.newyorker.com/online/blogs/photobooth/NASAEarth-01.jpg" alt="" />
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.
</div>
</div>
謝謝丹科 - 正是我在找什麼! – Aaron 2014-09-23 13:51:41