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
snxxwyy15mo 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.
Gabriel
GabrielOP15mo ago
Yes and how do you want me to align the carousel controls?
snxxwyy
snxxwyy15mo ago
You don’t have any in there. But you could most likely add a margin-inline: auto; to them.
Gabriel
GabrielOP15mo ago
What do you mean I dont have any in these? in there* Any what? The controls are to the right.
snxxwyy
snxxwyy15mo ago
Oh I’m sorry I couldn’t see them too well, they were white blended in haha, you want those under the text?
Gabriel
GabrielOP15mo ago
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
snxxwyy15mo 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;
}
Gabriel
GabrielOP15mo ago
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
snxxwyy15mo ago
you don't need to include the carousel in the flex container, only the title and controls, the carousel will automatically render underneath.
Gabriel
GabrielOP15mo ago
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
snxxwyy15mo ago
i'm honestly confused with what you want, the carousel in your image is underneath the title and controls.
Gabriel
GabrielOP15mo ago
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
snxxwyy15mo 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
Gabriel
GabrielOP15mo ago
Sure i'll try it out tomorrow
snxxwyy
snxxwyy15mo ago
sounds good
snxxwyy
snxxwyy15mo 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 👍.
Gabriel
GabrielOP15mo ago
Thanks for the help man I appreciate it, it works
snxxwyy
snxxwyy15mo ago
No worries!
Want results from more Discord servers?
Add your server