0
私は現在https://dev.shivampaw.com/meを開発しており、視差のある背景を作るべき「視差-bg」というクラスがあります。CSSの視差の背景
私の連絡先(セクション)は下部にありますが、私のヒーロー(上部)とテクスチャ(中)ではうまく動作していません。
これは私が使用していますjQueryのです:
$(window).scroll(function() {
var scrolledY = $(window).scrollTop();
$('.parallax-bg').css('background-position', 'center ' + ((scrolledY) - 70) + 'px');
});
を、コンタクトフォームセクションのためのCSSだけである:
section#contact{
background: linear-gradient(to bottom, rgba(0,0,0, 0.65) 0%,rgba(0,0,0, 0.65) 100%), url(https://www.shivampaw.com/images/bg-contact.jpg) no-repeat center -70px;
background-size: cover;
background-attachment: scroll;
color: white;
}
主人公のセクションのための:
section#hero{
background: linear-gradient(to bottom, rgba(0,0,0, 0.65) 0%,rgba(0,0,0, 0.65) 100%), url(https://www.shivampaw.com/images/top-bg.jpg) no-repeat center -70px;
background-size: cover;
background-attachment: scroll;
text-align: center;
color: white;
font-weight: bold;
padding-bottom: 50px;
}
誰がなぜこれが起こっているのか知っていますか?
おかげ
更新:視差によって私は一定の背景を意味します。私はjqueryを使うので、携帯電話でも動作します。
私はそれもテクスチャのために働いているとは思わない。それはちょうどそれのように "見える"ですが、テクスチャイメージは実際に動いていません。あなたの主人公のイメージと同じように動作しています - 画像は**固定**ですが、ウェブサイトはスクロールしています –
これをあなたのセクション 'background-attachment:fixed;' scroll'では変更/追加してみてください –
@NikhilNanjappaは私の更新を見ます – Shiv