My Angular
app's css structure is
-top level app has a css grid with 3 rows -nav component takes 1st row -content-component takes 2nd row -footer takes 3rd row
.css-grid-container{
height:100vh; /*height of the container is same ahs height of the view port.*/
display: grid;
grid-gap:20px;
grid-template-columns: 1fr; /* 1 columns*/
grid-template-rows: auto 15fr 1fr; /* 3 rows. Auto takes height of navigation, remaining is divided into 2 rows, middle row is 15 times larger than the 3rd row.*/
}
app-nav-component {
grid-column: 1 / -1;
grid-row: 1 / 2;
}
app-content-component{
grid-column: 1 / -1;
grid-row: 2 / 3;
}
app-footer-component{
grid-column: 1 / -1;
grid-row: 3 / -1;
}
The HTML is
<div class="body__div--background" >
<app-nav-component></app-nav-component>
<app-content-component></app-content-component>
<app-footer-component></app-footer-component>
</div>
The content component in the middle is where I want to position my new components. ContentComponent
's html
code is
<div id="content-div">
<router-outlet></router-outlet>
</div>
The css is
#content-div{
height:100%;
display:grid;
grid-template-columns: 1fr; /* 1 columns*/
grid-template-rows: 1fr; /*1 row*/
}
The above component is suppose to act as a container for other components (the nav and footer always stay the same). Now I have another component, HomeComponent
. I want the HomeComponent
to be placed inside ContentComponent
at the center. The html
and css
I have written for that is
<div class="homepage-component-css-grid-container" id="home-page-component">
<app-practice-component></app-practice-component>
<app-create-component></app-create-component>
</div>
The css is
.homepage-component-css-grid-container{
display: grid;
grid-gap:20px;
grid-template-columns: 1fr 1fr; /* 2 columns*/
}
#home-page-component{
align-self:center; /*center of the content component*/
grid-column: 1 / -1;
grid-row: 1 / -1;
}
app-practice-component{
grid-column: 1 / 2;
align-self: center;
justify-self:end;
}
app-create-component{
grid-column: 2 / 3;
align-self: center;
justify-self:start;
}
My issue is that the HomeComponent
is not been displayed at the centre. See pic below. Interestingly, I notice that if, via browser's debug tool, I manually add align-self:center
in reboot.scss
, then the HomeComponent
moves to the center. But reboot.scss
is not my file. How could I align HomeComponent
to center
Pic 1 - behaviour I am observing. HomeComponent
not at center
Pic2 - If I add align-self:center
in reboot.scss