How to scale an object so it fits perfectly inside a collider?

So I’m building this invisible box where I can put an object in (triggers collider) and then the object should rescale to the size of the invisible box so it fits perfectly inside it and stays in the middle. It should work with all kinds of objects. So wheter I have a long sword or a small potion it should always scale to the size of the invisible box.

Is there a clever way to do this?

There are no colliders yet but I would like to add a collider slightly above every green circle. The collider would be my invisible box. The objects should float like you see on the picture

If you use a box collider, you can retrieve the size of the collider through its size property (a Vector3) then use that size to approximate a scale for the object you put inside it. You’d have to ensure you’re consistent on which space you choose to use (local or world), and just go from there.