pretty much the title.
backstory: I am designing a game engine in javascript based on absolute positioning and I really need to know if the absolute positioning coordinate itself is in the center of the image(which would be awsome!), or else in one of the corners, but if so, which corner?
I think it’s the top left corner, but I’m not sure.
I really need to know so I can work out collisions between images, and actually give the objects in the game boundaries other than rectangles. I am tinkering around now, but it would save me a lot of time and I would feel more secure if someone could just let me know for sure.
I have an image in a div, and I am setting all css properties in the style property of the div, including bottom, left, height, and width
Thanks!
You set the
topandleft… that’s how much space to give at the top and left of the element you’re positioning absolutely. Now if you don’t give it a width and height, you can usebottomandrightto make it so it takes up all the space except for whatever you specify in those style attributes.A simple demo should be enough to illustrate this…
I should mention that absolute means absolute to the origin of the body (top left corner of page). The exception to this is when the parent element of your absolutely positioned element is
position: relativeSee this demo