I'm a beginner at rails programming, attempting to show many images on a page. Some images are to lay on top of others. To make it simple, say I want a blue square, with a red square in the upper right corner of the blue square (but not tight in the corner). I am trying to avoid compositing (with ImageMagick and similar) due to performance issues.
I just want to position overlapping images relative to one another.
As a more difficult example, imagine an odometer placed inside a larger image. For six digits, I would need to composite a million different images, or do it all on the fly, where all that is needed is to place the six images on top of the other one.
Inline style only for clarity here. Use a real CSS stylesheet.
One issue I noticed that could cause errors is that in rrichter's answer, the code below:
should include the px units within the style eg.
Other than that, the answer worked fine. Thanks.
You can absolutely position
pseudo elements
relative to their parent element.This gives you two extra layers to play with for every element - so positioning one image on top of another becomes easy - with minimal and semantic markup (no empty divs etc).
markup:
css:
Here's a LIVE DEMO