jquery - How make fixed webkit-mask for div? -
suppose have 2 blocks div superposed, difference between them in lower block content div applied effect assume black-white filter -webkit-filter: grayscale (100%);
if div-block p2 reduced in size height , synchronize scrolling achieve transition effect of color content in black-white.
however, site try write designed mobile devices , ios have problem dynamic position scrolling. alternatively can use iscroll, slows work...
so idea came cut div-block id="p2" using webkit-mask mask , fix webkitmask relative page. more detail in gif-animation: http://outsins.com/mask.gif
<div id="scroll" style="-webkit-overflow-crolling:touch;left:200px;width:500px;height:500px;"> <div id="p1" style="position:absolute;width:500px;height:1000px;z-index:1;-webkit-filter: grayscale(100%);"> text </div> <div id="p2" style="position:absolute;width:500px;height:1000px;z-index:2; color: blue;-webkit-mask:url(heartmask.png) no-repeat center center;-webkit-mask-attachment: fixed;"> text </div> </div>
i put 2 superimposed block in common container , added -webkit-overflow-scrolling:touch. while scrolling 2 div-block (p1 , p2) move simultaneously. on top layer (id: p2), added webkitmask -webkit-mask: url (heartmask.png)
, make fixed: -webkit-mask-attachment: fixed;
thus, content should clipped mask supposedly should not move.
but -webkit-mask-attachment: fixed;
not work, , mask moved whole page http://outsins.com/mask2.gif
i did not find example -webkit-mask-attachment: fixed;
and think wrong somewhere
where mistake? how can fix this?
sorry bad english...
thank you
-webkit-mask-attachment: fixed;
not supported majority of browsers. supported chome , safari. (see browser compatibility in mdn).
try use position:fixed
div#p2
:
<div id="p2" style="position:fixed;"></div>
Comments
Post a Comment