background
prop, there are 2 CSS custom properties available for use to further customize background image(s). They are commonly used when multiple decorative background images are required.
none
will allow the background image to stay exactly at its specified width and height.contain
will allow the background image to be contained within its parent container. No cropping will happen to the image.cover
.center center
.<div style="position:relative;">
// This background image will not be cropped and it is positioned to center of the non-static parent container.
{% include '@bolt-elements-image/image.twig' with {
background: true,
attributes: {
src: 'path/image.jpg',
width: 500,
height: 500,
style: '--e-bolt-image-fit: contain; --e-bolt-image-position: center center;',
},
} only %}
// This background image will not stretch and it is positioned to top left of the non-static parent container.
{% include '@bolt-elements-image/image.twig' with {
background: true,
attributes: {
src: 'path/image.jpg',
width: 150,
height: 150,
style: '--e-bolt-image-fit: none; --e-bolt-image-position: top left;',
},
} only %}
</div>
<div style="position:relative;">
// This background image will not be cropped and it is positioned to center of the non-static parent container.
<img src="path/image.jpg" width=500 height=500 style="--e-bolt-image-fit: contain; --e-bolt-image-position: center center;" class="e-bolt-image e-bolt-image--bg" alt="">
// This background image will not stretch and it is positioned to top left of the non-static parent container.
<img src="path/image.jpg" width=150 height=150 style="--e-bolt-image-fit: none; --e-bolt-image-position: top left;" class="e-bolt-image e-bolt-image--bg" alt="">
</div>