How can I do this with flexbox? Elements Alignment

I would like to align the Big Title EXCLUSIVE MONCLER SERVICES with the carousel controls. That way, is there an easy way? I guess with flexbox there isn't?
No description
18 Replies
snxxwyy
snxxwyy2y ago
You don’t need flexbox for that, you can wrap the carousel and title in a div and add text-align: center; to the title.
Ionut Gabriel Marisescu
Yes and how do you want me to align the carousel controls?
snxxwyy
snxxwyy2y ago
You don’t have any in there. But you could most likely add a margin-inline: auto; to them.
Ionut Gabriel Marisescu
What do you mean I dont have any in these? in there* Any what? The controls are to the right.
snxxwyy
snxxwyy2y ago
Oh I’m sorry I couldn’t see them too well, they were white blended in haha, you want those under the text?
Ionut Gabriel Marisescu
Let's stay I want the text title in the center of the screen and the controls to the same height however they are aligned to the right, like in the layout Do you think is there any easy way to achieve what i want?
snxxwyy
snxxwyy2y ago
you know, i'm genuinely a little stumped on this myself haha, i might have overestimated this one. i don't believe i can get it to work in an efficient way at least, the best i've got so far is this however i'm not sure if the text is centered? Maybe it is? give it a try perhaps.
div {
display: flex;
align-items: center;
}

div :first-child {
margin-inline: auto;
}
div {
display: flex;
align-items: center;
}

div :first-child {
margin-inline: auto;
}
Ionut Gabriel Marisescu
What if I do display flex and the carousels are flex-end and the title is margin-auto? Maybe that will work hmm i'll think about it tomorrow
snxxwyy
snxxwyy2y ago
you don't need to include the carousel in the flex container, only the title and controls, the carousel will automatically render underneath.
Ionut Gabriel Marisescu
Yeah i mean, I don't want it to render under it It's not in the layout see? I mean in the figma Techincally they are both on the same line
snxxwyy
snxxwyy2y ago
i'm honestly confused with what you want, the carousel in your image is underneath the title and controls.
Ionut Gabriel Marisescu
Sorry its late, I meant What if I do display flex on the top div, and then the 2 divs thats inside it, are the controls and the title, the title will have margin:auto and the the carousel controls will be flex-end But yeah the carousel is right
snxxwyy
snxxwyy2y ago
you can't use flex-end in this way as you're not trying to align along the y axis. Additionally there's no justify-self for flex either. So you'd have to use margin-left: auto; to do the carousel controls. i'm sorry but what i've done is the most i can do unfortunately, it's probably quite a simple fix but we've both got to hope someone provides an explanation 👍, sorry i couldn't help much here. @abradores
Ionut Gabriel Marisescu
Sure i'll try it out tomorrow
snxxwyy
snxxwyy2y ago
sounds good
snxxwyy
snxxwyy2y ago
i just double checked it again, i'm pretty sure what i said let's you do what you want- https://codepen.io/deerCabin/pen/GRPExwO 👍.
Ionut Gabriel Marisescu
Thanks for the help man I appreciate it, it works
snxxwyy
snxxwyy2y ago
No worries!

Did you find this page helpful?