CMS Development

asacurry
Membre | Partenaire solutions Diamond
Membre | Partenaire solutions Diamond

Adding display: flex to a wrapper div

Résolue

Hello, 

 

I'm trying to vertically center an image in a responsive div using flexbox. I can assign display:flex to the group in the template editor, but upon inspecting the preview it looks like it needs to be applied to a .row-fluid that is wrapped around the images. 

 

Is there a way to apply the flex attribute to the immediate parent (which I can't seem to access using the layout editor), or have the .row-fluid div inherit it from a class applied to the module group?

0 Votes
1 Solution acceptée
stefen
Solution
Conseiller clé | Partenaire solutions
Conseiller clé | Partenaire solutions

Adding display: flex to a wrapper div

Résolue

Give your module group a custom class. Then in your stylesheet you can use the class as a way to pinpoint that row-fluid class like so:

.my-custom-class > .row-fluid-wrapper > .row-fluid {
  display: flex;
  align-items: center;
}
Stefen Phelps, Community Champion, Kelp Web Developer

Voir la solution dans l'envoi d'origine

5 Réponses
relabidin
Ancien salarié HubSpot
Ancien salarié HubSpot

Adding display: flex to a wrapper div

Résolue

Hi @asacurry,

 

This is a great question that goes a bit over my head. 

 

@ndwilliams3 and @stefen are our resident design experts. Would you mind taking a quick look here?

 

Rami  

0 Votes
stefen
Solution
Conseiller clé | Partenaire solutions
Conseiller clé | Partenaire solutions

Adding display: flex to a wrapper div

Résolue

Give your module group a custom class. Then in your stylesheet you can use the class as a way to pinpoint that row-fluid class like so:

.my-custom-class > .row-fluid-wrapper > .row-fluid {
  display: flex;
  align-items: center;
}
Stefen Phelps, Community Champion, Kelp Web Developer
Hawk-Steve
Contributeur de premier rang

Adding display: flex to a wrapper div

Résolue

Hi Stefan

 

Thanks for the answer, I've been looking into this for quite some time.

 

 

What had confused me is that I thought > was used left to right. Parent element > Child element, your answer seems to go the opposite direction child > parent/child > parent

0 Votes
asacurry
Membre | Partenaire solutions Diamond
Membre | Partenaire solutions Diamond

Adding display: flex to a wrapper div

Résolue

exactly what I needed, was missing the ">"....

 

Many thanks!

ndwilliams3
Conseiller clé

Adding display: flex to a wrapper div

Résolue

I agree with @stefen. That would be the best approach.