I want to publish on my page section with articles in rows if form of boxes. I use bootstrap grid system to make it responsive. I set width of boxes to be 100%. And I want height to be as the same as width. For this I wrote an javascript code to execute this task:
document.addEventListener("DOMContentLoaded", function(event) {
let width = document.querySelectorAll(".post-boxes .box");
width.forEach(item =>{
item.style.height = `${item.offsetWidth}px`
});
});
But the problem is it works only when DOM is loaded for the first time, and if screen size is change, height remain the same.
This is my photo of boxes: