Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Responsive images positioned over image

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?

like image 875
dclawson Avatar asked May 03 '13 15:05

dclawson


People also ask

How do I position one image on top of another?

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.

How do you make an image position absolute responsive?

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.

How do I fix image position in HTML?

HTML | <img> align Attribute The <img> align attribute is used to set the alignment of an image. It is an inline element.


1 Answers

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%;
}
like image 114
Marcel Gwerder Avatar answered Sep 21 '22 20:09

Marcel Gwerder