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.
<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>