Oh God, don't use scripting for that! CSS container queries have length units that are relative to the size of the container: