I have setup a jsfiddle of what i'm trying to do:
http://jsfiddle.net/MgcDU/3936/
#counter {
position: relative;
}
#over {
position:absolute;
left:33%;
top:43%;
}
The image of the cat is my background image which resizes as the browser resizes.
The ball image is absolutely positioned over the cat. How can I get the ball image to resize and stay in the same position as it is my default?
Add CSS. Add a relative div placed in the flow of the page. Set the background image as relative so as the div knows how big it must be. Set the overlay as absolute, which will be relative to the upper-left edge of the first image.
To make an image responsive, you need to give a new value to its width property. Then the height of the image will adjust itself automatically. The important thing to know is that you should always use relative units for the width property like percentage, rather than absolute ones like pixels.
HTML | <img> align Attribute The <img> align attribute is used to set the alignment of an image. It is an inline element.
Set your #counter
div to display: inline;
or add a wrapper with display: inline;
and set the max-width
of #over
to for example 10%
(DEMO):
#counter {
position: relative;
display: inline;
}
#over {
position:absolute;
left:33%;
top:43%;
max-width: 10%;
}
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