html - HTML/CSS 网页看起来不应该
问题描述
1)我的nav和aside不够高。他们不会在应该的地方开始,也不会在应该的时候结束。
2)我的部分(以及导航和旁边)不会在页面底部结束。
3) 我的页脚不在页面底部。
我正在使用 HTML 和 CSS。我目前正在使用谷歌浏览器。
我希望我的页面如下所示:
HTTP:
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Titulazo</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="manifest" href="site.webmanifest">
<link rel="apple-touch-icon" href="icon.png">
<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="css/normalize.css">
<link href="style.css" rel="stylesheet">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<header id = "MainHeader">
<h1>Main Header h1</h1>
<p>Hello world! This is HTML5 Boilerplate.</p>
</header>
<nav>
<h1>Nav h1</h1>
<ul>
<li>bla</li>
<li>bla</li>
<li>bla</li>
</ul>
</nav>
<section>
<h1>Section h1</h1>
<header>
<h1>Section header</h1>
</header>
<article>
<h1>Article h1</h1>
<p>Posted on <time datetime="2009-10-22">October 22, 2009</time></p>
<p>Article text</p>
</article>
<footer>
<h1>Section Footer</h1>
</footer>
</section>
<aside>
<h1>Aside h1</h1>
<p>Aside text</p>
</aside>
<footer id = "MainFooter">
<h1>Main Footer, copyright 2018, Álvaro Puertas</h1>
</footer>
<!-- Google Analytics: change UA-XXXXX-Y to be your site's ID. -->
<script>
window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;
ga('create', 'UA-XXXXX-Y', 'auto'); ga('send', 'pageview')
</script>
<script src="https://www.google-analytics.com/analytics.js" async defer></script>
</body>
</html>
CSS:
body{
width:100%;
position:absolute;
height:auto;
}
header#MainHeader{
width: auto;
height: auto;
background-color: orange;
margin: 20px;
}
nav {
position: relative;
float: left;
height: auto;
width:200px;
margin: 20px;
top: 0px;
background-color: lightblue;
bottom: 0px;
}
section{
width: 900px;
height: auto;
float: left;
top: 500px;
background-color: pink;
}
aside{
width: 200px;
height: 100%;
margin: 20px;
top: 0px;
float: right;
background-color: lightgreen;
}
footer#MainFooter{
width: auto;
height: auto;
background-color: gray;
margin: 20px;
clear:both;
}
解决方案
body{
width:100%;
position:absolute;
height:auto;
margin: 0;
}
/*mycode*/
header p{
margin-bottom: 0;
}
header#MainHeader{
width: auto;
height: auto;
background-color: orange;
margin: 20px;
}
nav {
position: relative;
float: left;
height: 100%;
min-height: 75vh;
width:15%;
margin: 0 20 10px 20px;
top: 0px;
background-color: lightblue;
bottom: 0px;
}
section{
width: 64%;
min-height: 75vh;
float: left;
top: 500px;
background-color: pink;
}
aside{
width: 15%;
height: 100%;
min-height: 75vh;
margin: 0 20 10px 20px;
top: 0px;
float: right;
background-color: lightgreen;
}
footer#MainFooter{
width: auto;
height: auto;
background-color: gray;
margin: 20px;
clear:both;
}
这不是最好的做法。我建议您学习引导网格布局并学习使用 chrome 开发人员工具。
推荐阅读
- javascript - 是否可以使用旋转的标题单元格制作粘性表格标题?
- selenium-webdriver - 连接被拒绝时测试失败:连接
- c++ - C++ destructor recycling
- r - 如何分隔同名下同一个变量的两个值?
- scala - 处理 scala ZIO 中的错误
- c# - 重新加载实体时的性能问题
- c# - 如何在 C# 中复制 CAPICOM SignedData.Sign() 方法
- python - 如何连接行直到找到一个应该是新行的字符串..使用python?
- performance - 负载测试 api 时 IIS 对几乎备用请求的 403 错误响应
- python - 无法安装整齐