So I am making a header for my website. The title should be in the center of the page. On each side of the title should be an image of a chain. Because I want my website to look good on pc and mobile, I want to makte the chain as long as it needs to be to fill up the space. So I made a long chain image but I have some trouble cutting it off right. the image shouldn’t be stretched in any way. I made a drawing of the layout:
I tried quite some things but nothing even remotely resembles what I want to have. I’m still a beginner when it comes to html and css.
2
Answers
The easiest way would be to make two background images, set their position to
left center
on right side andright center
on left side. Then set it’s size to the actual size of your image, or use percentages to keep aspect ratio.Other good way would be to use pattern instead of a single image, because pattern can repeat indefinitely.
If you are using an img tag, the css proprety you are looking may be
object-fit: cover;
, combined with fixed height on your img. It will work for small resolutions, but with extra large screen widths, you may run into the opposite problem : the top and bottom of your picture being cropped by the object-fit due to the smaller height.For that matter, the best practice may be using a background image, and as you are speaking of a ‘chain’, a
background-repeat: repeat-x
with a repeatable pattern will cover every width possible.