I am trying to create a full screen responsive background image (like css background-size:cover) that contains divs that keep there exact position on the image whilst being scaled via a browser resize.
<div class="full_Screen_background">
<div class="image_to_fill_and_scale_fullscreen">
<div class="content_to_be_scaled_with_window_resizing">
</div>
</div>
</div>
And the css:
.content_to_be_scaled_with_window_resizing{
border:5px solid #000;
position:absolute;
top:30%;
left:40%;
height:10%;
width:10%;
}
.image_to_fill_and_scale_fullscreen{
background: url(../4706825697_c0367e6dee_b.jpg);
position: relative;
background-size: cover;
background-position: center;
background-attachment: scroll;
height: 100vh;
background-repeat: no-repeat;
}
The desired outcome is to have the div perfectly scale proportionally with the image as the browser is resized.
Any ideas would be much appreciated?
I tried it with a canvas. Hope that works for you. I fixed the rectangle to the head of the biker.
Edit: I used a hidden image to get the aspect ratio right.