Edit with possible solution below the code
The site has a full page video.
Scroll action: not to display content which is located 250px or less from the top — so 250px of top of the video is always visible.
Perhaps a better way to understand this: hide content underneath a transparent div
. But I think the first explanation is more code relevant.
Second explanation leads to numerous questions and semi-answers. None of them however solves my problem.
Here's an unanswered question that covers a lot: How to hide content that is scrolled under a transparent div?
I'd prefer the scroll bar to be full height.
Maybe this could be a hint: Add a class to a DIV when top of the window reach a specific element and remove it when not
This code could detect content position. Now to hide this upper overflow.
Demo
http://jsfiddle.net/4TgmF/
HTML
<div id="header">
<video autoplay loop poster="https://dl.dropboxusercontent.com/u/9200106/rsz_dreamstimefree_252880.jpg" id="bgvid">
<source src="video.mp4" type="video/mp4">
<source src="video.ogv" type="video/ogg">
</video>
<div id="visible_part">Part of the background that shoud be visible at all times. This DIV and its styling is for demonstration only</div>
</div>
<div id="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.</p>
</div>
CSS
* { margin:0; }
html, body {
width:100%;
height:100%;
}
#header {
width:100%;
height:100%;
}
#bgvid {
position:fixed;
z-index:-1000;
width:auto;
height:auto;
min-width:100%;
min-height:100%;
}
#visible_part {
position:fixed;
height:250px;
border-bottom:1px solid rgba(255,255,255,0.1);
color:#fff;
background:rgba(0,0,0,0.1);
}
#content {
width:100%;
min-height:100%;
background:#fafafa;
}
Edit
Gajus Kuizinas suggested in comments to replicate the background and use it as a mask, which doesn't really solves the problem, but he got me thinking (thanks). The key word here is mask. I found a good article on this: http://thenittygritty.co/css-masking
I think this could be a great solution. The mask would have position:fixed;
, top:250px;
, height:100%;
(-250px). The only problem is I can't figure out how to do a mask with fixed position and scrollable content. Can you see what I mean?