CSS grid layout enables you to create website layouts easily, by using a kind of "ASCII art" syntax. See the grid tutorial to learn how it works. The following templates all use the CSS grid layout.
HTML
Before we start writing code first, we need to create a primary structure of the HTML document, so that the browser can understand and start working. The basic HTML structure looks like the following.
After writing the primary structure of the HTML document, you will also write the tags and content you need. After that, you can see the output in your browser. We know that HTML Sudu Mae is used for exposing content in a basic format. To complete our content we need to use CSS, which is an HTML insert and it creates an engaging user interface.
<!DOCTYPE html>
<html>
<head>
<title>css grid</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<main>
<div class="div1">Header</div>
<div class="div2">Box1</div>
<div class="div3">Box2</div>
<div class="div4">Box3</div>
<div class="div5">Sideber</div>
<div class="div6">Main Content</div>
<div class="div7">Footer</div>
</main>
</body>
</html>
CSS
Now, we have time to improve the HTML content, for that, we need to add CSS to the HTML file. CSS can be added to HTML documents in a total of three ways, here we are using outside CSS design using CSS will arrive here after typing and see the output in your browser. *{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
text-align: center;
}
main{
width: 75%;
margin: 50px auto;
border: 1px solid gray;
display: grid;
color: white;
grid-template-rows:60px 100px 200px 60px;
grid-template-columns: repeat(3, 1fr) 150px;
grid-gap: 20px;
}
.div1{
background-color: #000;
grid-column: 1/-1;
}
.div2{background-color: #2ed573}
.div3{background-color: #1e90ff}
.div4{background-color: #5352ed}
.div5{
background-color: #ff0000;
grid-row: 2/4;
grid-column: 4/5;
}
.div6{
background-color: #263fbf;
grid-column: 1/4;
}
.div7{
background-color: #000;
grid-column: 1/-1;
}
No comments: