2017-09-13 90 views
0

我知道這已被回答,但我希望有人向我展示如何在移動設備和平板電腦視圖上禁用我的特定代碼。 每當我使用視差,然後在手機或平板電腦上查看我的網站時,它都會將圖像放大到根本無法辨認的位置。我怎樣才能避免這種情況? 謝謝。如何禁用移動設備和平板電腦視圖上的視差?

.parallax { 
 
    height: 800px; 
 
    width: 100%; 
 
    background-attachment: fixed; 
 
    background-position: 50% 50%; 
 
    background-repeat: no-repeat; 
 
    background-size: cover; 
 
}
<div class="parallax" style="background-image: url('https://s3.amazonaws.com/media.ohi/15678_vegancooking_2o.jpg');"> 
 
    <p class="photog" style="color:#FFF;">name here</p> 
 
</div>

回答

0

試試這個

@media only screen and (max-width:749px) { 
    .parallax { 
    background-attachment: scroll; 
    background-size: 100% 100%; 
    } 
} 

樣品fiddle ..

+0

這沒有奏效,圖片在移動視圖上仍然很放大。 – johnstont05

+0

你是什麼意思? – johnstont05

+0

我的意思是背景大小..看看這[小提琴](https://jsfiddle.net/wcv7s1b7/2/).. –

2

試試這個

@media only screen and (max-width:749px) { 
    .parallax { 
    background-attachment: inherit; 
    } 
} 

只是RES et移動背景附件。

相關問題