滚动时增加不透明度

时间:2014-11-30 17:04:04

标签: javascript jquery html css opacity

当我滚动时,我希望文本以与图片相同的方式显示,并且不透明度增加。你能帮我解决这个问题吗?

Opacity effect

4 个答案:

答案 0 :(得分:1)

您可以在文本上设置2个图像(在顶部和底部),不透明度,位置固定或绝对,滚动文本图像将在底部文本和顶部文本上方:) 希望我帮助你!!祝好运! :)

答案 1 :(得分:1)

您可以使用背景渐变创建两个<div>来完成此效果。

以下是两个显示我的意思的JSFiddles:

- Example w/ Code

- Fullscreen Result

答案 2 :(得分:0)

尝试this代码,类似代码的示例:

body {
    height: 500px;
}
.Top {
    position: absolute;
    background-image: url(http://afkarco.ir/images/Bottom.png);
    top: 0;
    right: 0;
    width: 100%;
    height: 100px;
    z-index: 10;
}

marquee {
    margin: 100px 0;
    height: 500px;
}

.Bottom {
    position: absolute;
    background-image: url(http://afkarco.ir/images/Top.png);
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100px;
    z-index: 10;
}

Demo

答案 3 :(得分:0)

我猜你的图片中的网站使用堆叠的.png -s来创建效果。如果您不想使用图像,可以使用带有框阴影的封面div伪造它:

html,
body {
  height: 100%;
  width: 100%;
  padding: 0;
  margin: 0;
}
p {
  padding: 20px 50px
}
.pCover {
  position: fixed;
  top: 0;
  height: 100%;
  width: 100%;
  background: transparent;
  box-shadow: 0 0 30px 40px #fff inset;
}
<div class="pCover"></div>
<p>
  Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit​​, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas,
  imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium. Qui animated corpse, cricket bat max brucks terribilem incessu zomby. The voodoo sacerdos flesh eater, suscitat mortuos comedere carnem virus. Zonbi tattered for solum
  oculi eorum defunctis go lum cerebro. Nescio brains an Undead zombies. Sicut malus putrid voodoo horror. Nigh tofth eliv ingdead. Cum horribilem walking dead resurgere de crazed sepulcris creaturis, zombie sicut de grave feeding iride et serpens. Pestilentia,
  shaun ofthe dead scythe animated corpses ipsa screams. Pestilentia est plague haec decaying ambulabat mortuos. Sicut zeder apathetic malus voodoo. Aenean a dolor plan et terror soulless vulnerum contagium accedunt, mortui iam vivam unlife. Qui tardius
  moveri, brid eof reanimator sed in magna copia sint terribiles undeath legionis. Alii missing oculis aliorum sicut serpere crabs nostram. Putridi braindead odores kill and infect, aere implent left four dead. Lucio fulci tremor est dark vivos magna.
  Expansis creepy arm yof darkness ulnis witchcraft missing carnem armis Kirkman Moore and Adlard caeruleum in locis. Romero morbo Congress amarus in auras. Nihil horum sagittis tincidunt, zombie slack-jawed gelida survival portenta. The unleashed virus
  est, et iam zombie mortui ambulabunt super terram. Souless mortuum glassy-eyed oculos attonitos indifferent back zom bieapoc alypse. An hoc dead snow braaaiiiins sociopathic incipere Clairvius Narcisse, an ante? Is bello mundi z? In Craven omni memoria
  patriae zombieland clairvius narcisse religionis sunt diri undead historiarum. Golums, zombies unrelenting et Raimi fascinati beheading. Maleficia! Vel cemetery man a modern bursting eyeballs perhsaps morbi. A terrenti flesh contagium. Forsitan deadgurl
  illud corpse Apocalypsi, vel staggering malum zomby poenae chainsaw zombi horrifying fecimus burial ground. Indeflexus shotgun coup de poudre monstra per plateas currere. Fit de decay nostra carne undead. Poenitentiam violent zom biehig hway agite RE:dead
  pœnitentiam! Vivens mortua sunt apud nos night of the living dead. Whyt zomby Ut fames after death cerebro virus enim carnis grusome, viscera et organa viventium. Sicut spargit virus ad impetum, qui supersumus flesh eating. Avium, brains guts, ghouls,
  unholy canum, fugere ferae et infecti horrenda monstra. Videmus twenty-eight deformis pale, horrenda daemonum. Panduntur brains portae rotting inferi. Finis accedens walking deadsentio terrore perterritus et twen tee ate daze leighter taedium wal kingdead.
  The horror, monstra epidemic significant finem. Terror brains sit unum viral superesse undead sentit, ut caro eaters maggots, caule nobis.
</p>