Can you assist me in recreating my idea from an image?
I am having trouble understanding how to select and place other elements, and then return them to their original positions after deselecting...
I attempted to use a grid but it did not work properly...
Here is the code I have that displays the child elements:
function toggleAdditionalGrid(clickedElement) {
var section = clickedElement.closest('.shopify-section');
var additionalGrid = section.querySelector('.dt-sc-additional-grids');
if(window.innerWidth<1020){
if(additionalGrid.style.display=='none' ){
additionalGrid.style.cssText='display: flex; flex-wrap: wrap;justify-content: center;flex-direction: column;align-content: center;';
}
else {
console.log(window.innerWidth);
additionalGrid.style.cssText='display: none; grid-template-columns: repeat(4, 25%) !important; margin: auto; width: 100% !important;justify-content: center !important; @media (max-width: 1020px) {display: none; flex-wrap: wrap;justify-content: center;flex-direction: column;align-content: center;}';
}
}
else{
if(additionalGrid.style.display=='none' ){
additionalGrid.style.cssText='display: inline-grid; grid-template-columns: repeat(4, 25%) !important; margin: auto; width: 100% !important;justify-content: center !important;';
}
else{
console.log(window.innerWidth);
additionalGrid.style.cssText='display: none; grid-template-columns: repeat(4, 25%) !important; margin: auto; width: 100% !important;justify-content: center !important; @media (max-width: 1020px) {display: grid;grid-template-columns: repeat(1, 100%) ;justify-content: center;flex-direction: column;align-content: center;}';
}
}
};
I simply need a code that will expand the clicked element and display its child elements.