@SvitlanaSuslenkova
Posted
You have <main> and <div class="container">. You don't need two, just one is fine. Also when you want to align project to the center with flex or grid add min-height: 100vh; As now your aligns everything to the center of it's height, not to the center of your view. Hope you found this comment helpful :)
@RajanCP
Posted
@SvitlanaSuslenkova Hi Svitlana, I only added <main> since someone earlier said it is semantically correct to include it but I agree with you.
Also, wouldn't using "min-height:100vh" stretch the container to the full height of the viewport which looks odd. Am I adding this in the wrong place?
@SvitlanaSuslenkova
Posted
@RajanCP you have max-height not to stretch anything too much
@RajanCP
Posted
@SvitlanaSuslenkova Sorry I think I don't understand.
@SvitlanaSuslenkova
Posted
@RajanCP you have to add flex to the parent component. It's the component inside which you want to center your project. Try:
body { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; }
Marked as helpful
@RajanCP
Posted
@SvitlanaSuslenkova Yes, that appears to have kept it centred regardless of whether I zoom in and out. Sorry to ask again, but why does the min-height: 100vh keep it centred? How would you say what the code does in plain English.
@SvitlanaSuslenkova
Posted
@RajanCP your project was centered before min-height: 100vh; The problem is that it centers to it's height and it's height is not full height of the screen, but the height of your content.
@RajanCP
Posted
@SvitlanaSuslenkova I see, thank you