as a teen, i was constantly harassed by adults enforcing ''dress codes'' on me. I very much experienced this as sexual harassment. I think this is one of many cases where people would more easily understand this as sexual harassment if I described it as if it happened to an adult.
imagine being on your lunch break, and your supervisor comes over to your table, tells you to stand up in front of everyone. they draw everyone's attention to your thighs. they tell you that you have broken the dress code because of the length of your shorts. they tell you to go change (so you do not get the rest of your lunch break). they do this every single day at lunch. every day. so you read the whole dress code front and back, and you choose your clothing carefully to not break it. you bring a cloth tape measure with you to work because they will not believe you. this time when your supervisor tells you that you're breaking dress code, you pull out your tape measure and show that you are within the limit. your supervisor says "I bet you wouldn't want me to bring you to the boss and let him measure it, would you?" it's clearly a threat: if you don't obey then you will be put alone in a room with your boss and he will touch your thighs. you don't know how to respond. you're taken out of lunch again.