I want my page to not exceed 1200px and be located at the center. so in the main div of the page I set: max width = 1200 px and layout = align top center. but the div still remain at the left. how could I solve this? thanks
Tom Ireland
1 month ago
Dec 10, 2024, 2:27 PM
You'll need to apply that to a child of the root div I think. The root div will always be the viewport size, so best to set that at flex and then center a child div inside with your max-width parameters. ๐
Tom Ireland
1 month ago
Dec 10, 2024, 2:29 PM
Actually, I might be mistaken. I think for the root, you could apply position or margin to center but your background will assume the browser default background colour I think.
Tom Ireland
1 month ago
Dec 10, 2024, 2:32 PM
You can use margin: 0 auto on the root to achieve what you want but the background will default to what toddle sets and that is white (see below). I'd opt for child element and use flex to center it instead.
ssssadsadasd
1 month ago
Dec 10, 2024, 2:48 PM
@Tom Ireland thanks. you mean 0 on all margins (see pic)? I am using the 2nd version since I have some reusables and they dont seem to behave well when I implement your first solution
You can see the blue outline around the entire preview
You don't need left/right settings here either. 100% width is enough
Lucas G
1 month ago
Dec 10, 2024, 4:27 PM
Ah sorry, I see what you are trying to do. I thought you were talking about children divs. Tom had already answered it
Margin or align-self: center would do it
I would use align-self
ssssadsadasd
1 month ago
Dec 10, 2024, 4:46 PM
@Lucas G thanks the align-self works. the only thing is that the components used do not move accordingly
Lucas G
1 month ago
Dec 10, 2024, 4:51 PM
How are the components positioned?
ssssadsadasd
1 month ago
Dec 10, 2024, 4:54 PM
this is the div which holds the sidebar
ssssadsadasd
1 month ago
Dec 10, 2024, 4:58 PM
and the sidebar itself. I think it is related to this.
Tom Ireland
1 month ago
Dec 10, 2024, 5:02 PM
The sidebar is set to Fixed at 0px, which means it will break out of the flow. I would use Absolute and set top and left to 0px as one way to fix that.
ssssadsadasd
1 month ago
Dec 10, 2024, 5:25 PM
@Tom Ireland hmm I dont think it is working as expected
ssssadsadasd
1 month ago
Dec 10, 2024, 6:22 PM
@Tom Ireland@Lucas G so yeah. the align-self only aligns the elements on the page and not the components. I tried to make the sidebar flex but it changed nothing
Position fixed is relative to the viewport, not its parent element
So to position the sidebar, make it absolute instead
display: flex is a different property from position property
ssssadsadasd
1 month ago
Dec 10, 2024, 8:09 PM
@Lucas G I am not sure implemented it correctly, but it does not solve the problem ๐
Lucas G
1 month ago
Dec 10, 2024, 8:12 PM
I'd update a few things on that. It's hard to fully troubleshoot it without taking a look though
ssssadsadasd
1 month ago
Dec 10, 2024, 8:30 PM
@Lucas G I have kept a very similar structure to the "dashy" template (i.e. sidebar component and a nav component that contains the sidebar component) except some custom changes. also are you part of the toddle team? asking because I could dm you the link to my app if that is fine. thanks