要素内で文字数がバラバラな場合、高さが揃わず見た目が悪いので、一番文字数が多い要素の高さに合わせる方法
最下部、「matchHeight」に高さを揃えたい要素のクラスを指定
function matchHeight(targetElement) {
const targetElements = document.querySelectorAll(targetElement)
if (targetElements.length > 1) {
let heightArray = []
targetElements.forEach((element) => {
const height = element.clientHeight
heightArray.push(height)
})
const maxHeight = Math.max(...heightArray)
targetElements.forEach((column) => {
column.style.height = maxHeight + 'px'
})
}
}
window.addEventListener('load', () => {
matchHeight('.thumText h3', '.thumText p')
})