In my project, I need to show a small image in the center of the visible part of the container with respect to the ie window.loader . Even when the user scrolls the page, the image should be visible in the center .loader.
I successfully implemented this, but now I have come across edgecase, when the user scrolls the page “to the header” or “to the footer”, the small image is hiding. demo .
This is normal behavior, but in these edgecases I want the image to adhere to the top / bottom end of the container .loader.
What I want:
- Keep the small image always in the center of the container
.loader. (I already implemented this) - when scrolling to any end of the container, the
.loader image should adhere to this end, and not hide behind the container.
Fiddle
A solution using only css is preferred. I am looking for browser support in IE9 +, chrome and firefox.
.header {
height: 600px;
width: 650px;
background-color: grey;
}
.left-side {
height: 300px;
width: 150px;
float: left;
background-color: red;
}
.loader {
background-image: url('http://i.imgur.com/U2njI.jpg');
margin-left: 150px;
height: 1500px;
width: 500px;
background-position: 345px center;
background-repeat: no-repeat;
background-attachment: fixed;
background-color: cornflowerblue;
}
.footer {
height: 600px;
width: 650px;
background-color: silver;
}
<div class="header"></div>
<div class="left-side"></div>
<div class="loader"></div>
<div class="footer"></div>
Run codeHide result
source
share