r/learnreactjs • u/roger_master_control • Oct 09 '22
Does React, or web in general, have a "constraint" layout like Android and iOS do?
Hi all,
In Android and iOS a "constraint" layout lets you arrange components relative to each other, like "Button A" is pinned to the left side of the container, and "Button B" has its left side pinned to the right side of "Button A", and "Doodad C" has its top pinned to the bottom of "Button B", and so on.
As far as I can tell this isn't a thing in React, or in web in general.
Am I missing something, or is this just not a concept in web dev?
Thanks!
4
Upvotes
2
u/[deleted] Oct 09 '22
You can use position: relative on a container element and position absolute on the button. Then set the left: 0. This will pin it to the left of the container. You can also use top, right, and bottom depending on what you would like it to "stick" to.
3
u/Mathematitan Oct 09 '22
CSS has these features but they’re not named in any consistent way. Instead of trying to replicate these layout paradigms instead learn CSS box model, flex box and grid.