0
有問題的設計是:http://hthworldwide.net/如何重新創建此漸變不透明度,固定背景設計?
我特別試圖重新創建登陸/英雄元素,在滾動時淡化不透明度以在背景中顯示固定圖像。
我已經得到了一些接近,但我似乎無法指責這件事。問題是我無法讓白色濾鏡在整個屏幕上伸展,而不會給透明字母賦予白色背景。理想情況下,您應該能夠通過示例中所示的文本查看背景圖像。
這是我到目前爲止有:http://codepen.io/rsprice/pen/reVazo
HTML:
<div class="background"></div>
<div class="opacity-layer"></div>
<div class="text"></div>
<div class="other"></div>
CSS:
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
.background {
width: 3000px;
height: 1000px;
background-position: 0px -300px;
background-size: 130%;
box-sizing: border-box;
z-index: -1;
position: fixed;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
margin: 0;
padding: 0;
color: white;
background: url('https://images.unsplash.com/photo-1454496522488-7a8e488e8606?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=a9504411622da8e65df977606f82479c');
}
.opacity-layer {
transform: rotateZ(360deg);
-webkit-perspective: 1000;
box-sizing: border-box;
position: relative;
width: 2000px;
min-height: 100%;
background-size: cover;
background-position: center top;
overflow: hidden;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
margin: 0;
padding: 0;
}
.text {
height: 300px;
width: 100%;
background-position: center;
background: url('http://hthworldwide.net/sites/all/themes/hthworldwide/style/images/home-intro.png') no-repeat;
background-color: transparent;
padding: 0;
margin: 0;
}
.text img {
margin: 0 auto;
}
.other {
height: 2000px;
}
的jQuery:
$(window).scroll(function(){
$(".opacity-layer").css("opacity", 1 - $(window).scrollTop()/250);
});
感謝您的詳細解釋,Alvaro!對此,我真的非常感激。 – ryanprice