62
loading...
This website collects cookies to deliver better user experience
<xmp><div class="container"><header>
<!-- Header --></header>
<nav>
<!-- Nav Bar --></nav>
<main>
<!-- Main Content --></main>
<aside>
<!-- Sidebar --></aside>
<footer>
<!-- Footer --></footer></div>
</xmp>
<xmp>
.container {
display: grid;
grid-template-columns: 220px 1fr 220px;
grid-template-rows: auto 1fr auto;
grid-gap: 12px;
grid-template-areas:
"header header header"
"nav content side"
"footer footer footer";
height: 100vh;
}
</xmp>
ng new angular-css-grid
Would you like to add Angular routing? Yes
Which stylesheet format would you like to use? CSS
Cd angular-css-grid
ng serve --open
ng g c header
ng g c nav
ng g c main
ng g c aside
ng g c footer
ng g c privacy-policy
<xmp>
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MainComponent } from './main/main.component';
import { PrivacyPolicyComponent } from './privacy-policy/privacy-policy.component';
const routes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: 'home' },
{ path: 'home', component: MainComponent },
{ path: 'privacy-policy', component: PrivacyPolicyComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
</xmp>
<xmp><div class="container">
<app-header></app-header>
<app-nav></app-nav>
<router-outlet></router-outlet>
<app-aside></app-aside>
<app-footer></app-footer></div>
</xmp>
<xmp><header><h2>Angular CSS Grid</h2></header>
</xmp>
<xmp><nav><ul><li></li><li><a routerlink="/home">Home</a></li><li></li><li><a routerlink="/privacy-policy">Privacy Policy</a></li><li></li></ul></nav>
</xmp>
<xmp><aside><h3>Sidebar</h3></aside>
</xmp>
<xmp><footer>
<span>
@Copyright 2020-2021
</span></footer>
</xmp>
<xmp><main><p>
Main content part.</p></main>
</xmp>
<xmp>body {
margin: 0;
padding: 0;
font-family: sans-serif;
background-color: #E4F0FF;
}
.container {
display: grid;
grid-template-columns: 200px 1fr 200px;
grid-template-rows: auto 1fr auto;
grid-gap: 12px;
grid-template-areas:
"header header header"
"nav content side"
"footer footer footer";
height: 100vh;
}
app-header {
color: white;
font-size: 14px;
grid-area: header;
text-align: center;
background-color: #a5282898;
}
app-nav {
grid-area: nav;
margin-left: 0.6rem;
background-color: #167299a4;
}
app-privacy-policy,
app-main {
grid-area: content;
background-color: #89ebbd70;
padding: 25px;
}
app-aside {
grid-area: side;
margin-right: 0.6rem;
background-color: #167299a4;
}
app-footer {
grid-area: footer;
background-color:#2ca159c2;
color: white;
text-align: center;
padding: 25px 0;
}
ul li {
color: white;
}
ul li a {
color: white;
text-decoration: none;
display: inline-block;
margin-bottom: 15px;
}
@media (max-width: 991px) {
app-nav,
app-aside {
margin: 0;
}
.container {
grid-template-columns: 1fr;
grid-template-areas:
"header"
"nav"
"content"
"side"
"footer";
grid-template-rows:auto minmax(60px, auto) 1fr minmax(70px, auto) auto;
}
}
</xmp>
<xmp>
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { NavComponent } from './nav/nav.component';
import { MainComponent } from './main/main.component';
import { AsideComponent } from './aside/aside.component';
import { FooterComponent } from './footer/footer.component';
import { PrivacyPolicyComponent } from './privacy-policy/privacy-policy.component';
import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [
AppComponent,
HeaderComponent,
NavComponent,
MainComponent,
AsideComponent,
FooterComponent,
PrivacyPolicyComponent
],
imports: [
BrowserModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
</xmp>