I am attempting to get a background-attachment:fixed
effect, as in this article from Chris Coyer.
My goal is to make this effect responsive, but my concern is that the specified sizes rely on the px size, which is not responsive.
Therefore, I created the below example with two "windowed" images: WD2 and WD4. The 2nd one (WD4) shows the desired effect, but it relies on the px size. Therefore, I am trying to make the first one (WD2) grow its background image to create the same effect as in WD4.
Since placekitten serves px-sized images, I am beginning with a smaller image and trying to grow it to fit the desired size. Trying to "grow" the smaller image is my testing approach - I am not committed to this example. If anyone can create a better test/example, please do.
HTML:
<div id="wd1"></div>
<div id="wd2">
<div id="d2"></div> <--- small image. Cannot expand and get desired effect
</div>
<!-- --------------------------------------------- -->
<div id="wd3"></div>
<div id="wd4">
<div id="d4"></div> <--- Large image - Works! But need to grow a small image
</div>
<div id="wd5"></div>
CSS:
#wd1{width:100%;height:400px;background:red;}
#wd2{width:100%;height:200px;background:url(http://placekitten.com/98/48) 100% 300% no-repeat;}
#d2 {width:100%;height:200px;}
#wd3{width:100%;height:800px;background:green;}
#wd4{width:100%;height:200px;background:url(http://placekitten.com/798/501) no-repeat fixed;}
#d4 {width:100%;height:200px;}
#wd5{width:100%;height:500px;background:green;}
I found these two SO questions, but I cannot see how to use them to make my example work:
Can background image extend beyond div's borders?
Stretch and scale a CSS image in the background - with CSS only