Style tag relative to overflow container width

How would i style an item in an overflowing div container according to the width of the container (NOT the content inside the container)

Visual explanation: (https://i.stack.imgur.com/WGA92.png)

I achieved the effect with javascript, but that would also be needed to run on edge cases (closing sidebar, …)

document.addEventListener('resize', (e) => {
    const width = document.getElementsByClassName('scrollContainer')[0].clientWidth - 20
    document.querySelector('item-child').style.width = width + 'px'
})

It that possible without any js?