19 CEO Dashboard Examples for Business Leaders
Let's rewind to the 1990s. Data used to be stored on servers and CEOs relied on basic tools to make optimal decisions. No dashboards, nothing. When you use Power BI with a solid...
Kapil Panchal - August 23, 2021
Listening is fun too.
Straighten your back and cherish with coffee - PLAY !
Holy Grail is a web page user interface layout pattern. The header, main content section, left side fixed-width nav block, middle content section, fixed sidebar, and the footer at the bottom are among the UI components.
It may be created using a variety of techniques, including CSS Grid and the incredibly popular CSS Flex-box method. In this article, we'll use Angular to create the Holy Grail layout using CSS Grid.
Columns and rows are used in a CSS Grid Layout, and horizontal and vertical lines cross each other. This point of intersection creates a flexible arrangement on which items can be arranged in a logical order. To create a web page, a grid-based layout method eliminates the need for floats and position values.
This is the most appropriate and straightforward method for creating a UI layout in Angular. It also works with the most recent browsers, including Chrome, Safari, Firefox, and Edge.
So far, we've covered a basic overview of Holy Grill and CSS Grid layout. Then, with the help of HTML and current CSS, quickly develop a responsive Holy Grill layout in Angular 12 using CSS Grid.
Creating a flexible layout in Angular 12 was previously a challenge, but because of the introduction of the CSS Grid system, developing a responsive layout has become surprisingly straightforward. In Angular, making the layout responsive takes less code and time.
Grid-template-rows and grid-template-columns CSS attributes can be used to create a CSS grid with rows and columns. To begin with the grid structure, we must first comprehend its simple structure. It consists of a layout, responsive one or more child components.
Let's just have a glance at the CSS components that we utilized to make the Holy Grid layout with CSS Grid.
.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; }
By changing the display property to grid, we can turn a div container into a grid.
grid-template-columns and grid-template-rows are grid-template-columns and grid-template-rows, respectively. CSS3 properties are utilized to create a grid container class template.
We use the grid-gap attribute and a 12px gap between the grid row and columns to add gaping.
The grid-template-areas are a collection of grid-template-areas. Within the CSS grid layout, the designated grid regions CSS property defines.
In our grid layout, the height: 100vh gives the container 100 percent viewport height. We also set the height of the middle row to 1fr, and it will add extra space as needed.
Install and configure a basic Angular project using the following command to build up a Holy Grill layout inside an Angular app.
ng new angular-css-grid # ? Would you like to add Angular routing? Yes # ? Which stylesheet format would you like to use? CSSGet Inside the Project
Cd angular-css-gridRun the following command in the terminal to get the project started.
ng serve --open
To make a Holy Grail Layout,we will need to include the following components.
We must now create the Angular components.
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
Now that the components have been generated, it's time to add the Holy Grill layout to the Angular 12 components using CSS Grid.
To begin, add the following code to the app-routing.component.ts file.
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 { }
Include components for the home and privacy policy in the app-routing.module.ts file. The Urls in Angular CSS Grid app gets configured, and generated when the Angular app was installed and asked, "Would you like to add Angular routing?"
Add the header, nav, main, privacy policy, aside, and footer selectors to the app.component.html file.
The header, footer, and nav components in the Angular holy grail layout will serve the same text on the home and privacy policy pages.
To begin, add HTML to the header, nav, and footer components.
In the app/header/header.component.html file, insert the following code.
Angular CSS Grid
In the app/nav/nav.component.html file, insert the following code. In Angular, the routerLink=”” directive makes the routes clickable.
In the app/aside/aside.component.html file, insert the following code.
In the app/footer/footer.component.html file, insert the following code.
Insert the following code in the main/main.component.html file.
Main content part.
Include the following code in the app-privacy-policy.component.html file.
privacy policy part
After that, inside the styles.css file, add the final CSS code.
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; } }
The finished app.module.ts file can be seen here.
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 { }
In this blog, we've explored the core elements of CSS Grid layout and how to utilize it to create modern layouts for Angular developers. Finally, using the Holy Grill UI design, we constructed an Angular 12 CSS Grid layout.
Build Your Agile Team
Let's rewind to the 1990s. Data used to be stored on servers and CEOs relied on basic tools to make optimal decisions. No dashboards, nothing. When you use Power BI with a solid...
Imagine walking into a meeting where critical decisions need to be made—fast. You need clear, flexible data that you can analyze on the spot. But what if your insights are locked inside...
Clear insights mean smarter decisions, and this is what data storytelling does. It helps you speak a language that you quickly understand. Like for example, you are a CTO dealing with...