Is it possible to make a Dynamic Component that auto-resizes to fit between others?

I know I can make a DC as a part of another component which will resize based on dimensions of the parent or other groups.

But is it possible to make a DC that will resize to fit between other components / objects? (Not related to it)

For example, a vertical shelf divider that will, upon being clicked, fit into the vertical space between the shelves?

You should take a look to Profile Builder extension. It solves a lot of those problems easier than DC.