Skip to content

How to achieve a centered grid layout with rows that are left-aligned? #854

Answered by marc2332
bonsairobo asked this question in Q&A
Discussion options

You must be logged in to vote

hey! You were very close.

You just need to remove the 100% width and 100% height from the second rect. This way the inner rect will not be expanded to its parent size and instead will be shrinked to its children size, and thus it will be centered.

🔴

 rsx!(
        rect {
            width: "100%",
            height: "100%",

            direction: "vertical",
            cross_align: "center",

            rect {
                width: "100%",
                height: "100%",

                // Children are rows.
                direction: "vertical",
                main_align: "start",
                cross_align: "start",

 rsx!(
        rect {
            width: "100%",
            …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@marc2332
Comment options

@marc2332
Comment options

@bonsairobo
Comment options

@marc2332
Comment options

@marc2332
Comment options

Answer selected by bonsairobo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
2 participants