hello,
i want to create a rich text above the images to be like this :
this is my code :
<div class=“slider-container”>
<div class=“slider-content”>
{% for item in module.field_group %}
{% if item.image_field.src %}
{% set sizeAttrs = ‘width=“{{ item.image_field.width }}” height=“{{ item.image_field.height }}”’ %}
{% if item.image_field.size_type == ‘auto’ %}
{% set sizeAttrs = ‘width=“{{ item.image_field.width }}” height=“{{ item.image_field.height }}” style=“max-width: 100%; height: auto;”’ %}
{% elif item.image_field.size_type == ‘auto_custom_max’ %}
{% set sizeAttrs = ‘width=“{{ item.image_field.max_width }}” height=“{{ item.image_field.max_height }}” style=“max-width: 100%; height: auto;”’ %}
{% endif %}
{% set loadingAttr = item.image_field.loading != ‘disabled’ ? ‘loading=“{{ item.image_field.loading }}”’ : ‘’ %}
<img src=“{{ item.image_field.src }}” alt=“{{ item.image_field.alt }}” {{ loadingAttr }} {{ sizeAttrs }}>
{% endif %}
{% inline_rich_text field=“richtext_field” value=“{{ item.richtext_field }}” %}
{% endfor %}
</div>
<input type=“range” class=“slider-bar” min=“0” max=“2” step=“1” value=“0”>
</div>
.slider-container {
width: 100%;
overflow: hidden;
white-space: nowrap;
position: relative;
margin-bottom: 20px; /* Add space between the images and the input */
}
.slider-content {
display: flex;
width: calc(100% / 3);
box-sizing: border-box;
transition: transform 0.5s ease;
margin-right: 10px; /* Add space between the images */
}
.slider-content img {
width: 100%;
height: auto;
display: block;
transition: transform 0.5s ease;
}
.slider-bar {
width: calc(100% - 20px); /* Adjust width to accommodate thumb */
background-color: red; /* Set background color */
padding: 10px; /* Optional: Add padding for visual spacing */
border-radius: 5px; /* Optional: Add border radius for rounded corners */
}
.slider-bar input[type=“range”] {
width: 100%;
height: 5px;
-webkit-appearance: none;
background-color: transparent; /* Set transparent background */
outline: none;
border-radius: 5px; /* Optional: Add border radius for track */
}
.slider-bar input[type=“range”]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 20px;
height: 20px;
background-color: white; /* Set thumb color */
border-radius: 50%;
cursor: pointer;
margin-top: -8px; /* Adjust thumb position */
}
document.addEventListener(‘DOMContentLoaded’, function() {
const sliderContainer = document.querySelector(‘.slider-container’);
const slides = document.querySelectorAll(‘.slider-content img’);
const sliderBar = document.querySelector(‘.slider-bar’);
// Set initial scale for each image
slides.forEach((slide, index) => {
slide.style.transform = index === 0 ? ‘scale(1)’ : ‘scale(0.7)’;
});
sliderBar.addEventListener(‘input’, (event) => {
const value = parseInt(event.target.value);
updateScale(value);
});
function updateScale(currentIndex) {
slides.forEach((slide, index) => {
if (index === currentIndex) {
slide.style.transform = ‘scale(1)’;
} else if (index === 0 || index === slides.length - 1) {
slide.style.transform = ‘scale(0.7)’;
} else {
slide.style.transform = ‘scale(0.7)’;
}
});
}
});
please can anyone help me with that?
