CSS Grid Layout excels at dividing a page into major regions or defining the relationship in terms of size, position, and layer, between parts of a control built from HTML primitives. Like tables, grid layout enables an author to align elements into columns and rows.
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 layout</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<ul>
<li><div class="bottom">box1</div></li>
<li><div class="bottom">box2</div></li>
<li><div class="bottom">box3</div></li>
<li><div class="bottom">box4</div></li>
<li><div class="bottom">box5</div></li>
<li><div class="bottom">box6</div></li>
<li><div class="bottom">box7</div></li>
<li><div class="bottom">box8</div></li>
</ul>
</div>
</body>
</html>
<html>
<head>
<title>css layout</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<ul>
<li><div class="bottom">box1</div></li>
<li><div class="bottom">box2</div></li>
<li><div class="bottom">box3</div></li>
<li><div class="bottom">box4</div></li>
<li><div class="bottom">box5</div></li>
<li><div class="bottom">box6</div></li>
<li><div class="bottom">box7</div></li>
<li><div class="bottom">box8</div></li>
</ul>
</div>
</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;
}
.container{
width: 90%;
margin: auto;
overflow: hidden;
background: skyblue;
margin-top: 20px;
}
.container ul{
padding: 0;
margin: 0;
}
.container ul li{
float: left;
list-style: none;
width: 20%;
height: 300px;
background: red;
margin: 20px 0px 20px 55px;
border: 2px solid blue;
box-sizing: border-box;
}
.container ul li:hover{
opacity: 0.8;
}
.bottom{
width: 100%;
height: 50px;
line-height: 50px;
background: blue;
text-align: center;
color:white;
font-size: 20px
}
margin: 0;
padding: 0;
}
.container{
width: 90%;
margin: auto;
overflow: hidden;
background: skyblue;
margin-top: 20px;
}
.container ul{
padding: 0;
margin: 0;
}
.container ul li{
float: left;
list-style: none;
width: 20%;
height: 300px;
background: red;
margin: 20px 0px 20px 55px;
border: 2px solid blue;
box-sizing: border-box;
}
.container ul li:hover{
opacity: 0.8;
}
.bottom{
width: 100%;
height: 50px;
line-height: 50px;
background: blue;
text-align: center;
color:white;
font-size: 20px
}
css grid layout using html and css
Reviewed by easycoding
on
August 28, 2020
Rating:
No comments: