1
我真的很新开发网站。而且我在某处读到网格基本上是简单响应式设计的未来,所以我正在尝试使用它。现在我无法弄清楚包装类以外的元素如何跟随第一列的最大宽度。页脚外部网格布局后
下面是HTML
<!DOCTYPE html>
<html>
<head>
<title>GRID</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="userpage.css" />
</head>
<body class= 'wrapper'>
<div class= 'box header'>
<img src=''>
<ul class= 'nav-ul'>
<li class= 'nav-li'><a href='#'>Home</a></li>
<li class= 'nav-li'><a href='#'>About Us</a></li>
<li class= 'nav-li'><a href='#'>Contact</a></li>
</ul>
</div>
<!-- End of header -->
<div class= 'box left'>
box left
</div>
<div class= 'box right'>
box right
</div>
<div class= 'box contact'>
contact
</div>
</body>
<!-- End of Body -->
<footer>
This is the footer
</footer>
</html>
这里是CSS:
*{
padding: 0px;
margin: 0px;
}
.wrapper {
display: grid;
grid-template-columns: 50% 50%;
grid-template-areas:
"header header"
"body-l body-r"
"contact contact";
margin: 0px;
padding: 0px;
}
.box {
border-style: dotted;
border-color: red;
padding: 10px;
}
.header {
grid-area: header;
background-color: #1df9b7;
}
.left {
grid-area: body-l;
}
.right {
grid-area: body-r;
}
.contact {
grid-area: contact;
}
.nav-ul {
list-style: none;
float: right;
}
.nav-li {
float: left;
padding-right: 0.7em;
}
.nav-li a {
text-decoration: none;
color: white;
}
footer {
background-color: #00704e;
}
什么,我想是页脚,以填补该网站的其余区域。
那好吧,谢谢。但是,我如何让页脚填充页面的高度? – LRD27
最简单的方法是给身体一个100vh的高度,并给它一个你想要的页脚背景颜色。 –
查看更新后的代码片段。 (请注意,我还为内容添加了背景色以将其与页脚分开。) –