I have three sectioning areas and within these I have a header element and a child item that is position fixed.
As the user scrolls I want the next section to go over the previous section including its fixed child.
I have this working in Chrome by using backface visibility:
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
But in FF, the fixed items are no longer fixed. Take a look at the my jsfiddle http://jsfiddle.net/7KjXm/5/
Is this expected behaviour? Is there a cross browser solution? Or is JS the way to go?
Thanks....
The backface-visibility property defines whether or not the back face of an element should be visible when facing the user. The back face of an element is a mirror image of the front face being displayed. This property is useful when an element is rotated. It lets you choose if the user should see the back face or not.
Answer : The backfaceVisibility prop is used to hide the back face of a Image or View component. When we rotate a image or View in Y-Direction manner like horizontally. Then when view flip 180 degree it does display its back face or back part.
The back face is visible when turned towards the user. The back face is hidden, effectively making the element invisible when turned away from the user.
I managed to solve the effect you were looking for. Unfortunately, it does not seem possible to do with only css (yet).
Here is my solution that uses jquery and modified css of the original page. I switched to numbers instead of colored elements and changed the sizes.
My javascript for fake floating elements (allows for them to be hidden when the view moves away):
$(function(){
elem = $('.fixeditem');
win = $(window);
wrap = $('<div>').css({
width: elem.width(),
height: elem.height()
});
elem.wrap(wrap);
win.scroll(function() {
elem.each(function(index, element){
element = $(element);
var offset = element.parent().offset().top;
element.css('top', win.scrollTop() + 40 - offset);
});
});
});
My custom css for this specific example:
html, body{
height: 100%;
}
.item {
min-height:100%;
background-color: white;
position: relative;
z-index: 1;
overflow: hidden;
}
.header {
position: relative;
background-color: green;
padding: 5px;
z-index: 2;
}
.fixeditem {
position: relative;
top: 10%;
left: 50%;
z-index: 0;
}
Colored update of code: http://jsfiddle.net/8F2Zc/4/
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With