Flexible background positioning
✓ Published0🌍 Public
AAlexZ33
Last edited Nov 19, 2019
Created on Nov 19, 2019
This example demonstrates how to position a background image with precise offsets from the edges of a container using the CSS `calc()` function. The code sets a fixed background position of `calc(100% - 20px)` horizontally and `calc(100% - 10px)` vertically, ensuring the image stays 20 pixels from the right and 10 pixels from the bottom regardless of container size. A placeholder SVG image from `csssecrets.io` is applied as the background, with the text "Code Pirate" rendered inside the styled `div`. The example uses only standard CSS properties and no external JavaScript libraries.
AI-generated description