html - 正文出现在标题中?
问题描述
尝试向我的正文添加内容以继续我的网站流程,但正文中的任何内容都出现在标题的左上角。
为什么会发生这种情况的任何想法?
堆栈溢出要我写更多的内容。这是我写的更多内容。
<!DOCTYPE html>
<html>
<head>
<link href="flex.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css2?family=Frank+Ruhl+Libre:wght@500">
</head>
<header>
<div id="header">
<h1 class="title">brookfield corp</h1>
<nav class="top-nav">
<ul>
<a href="#recent"><li>recent</li></a>
<a href="#samples"><li>samples</li></a>
</ul>
</nav>
</div>
</header>
<body>
<h2>recent</h2>
</body>
</html>
html {
box-sizing: border-box;
}
.title {
font-family: 'Frank Ruhl Libre', serif;
text-align: center;
font-size: 4em;
background-color: hsla(140, 50%, 30%, .9);
color:cornsilk;
padding: 30px 0px 30px 0px;
margin: 0 auto;
height: 100px;
width: 100%;
top: 0px;
left: 0px;
position: absolute;
}
nav {
font-family: 'Frank Ruhl Libre', serif;
float: right;
text-decoration: none;
}
li {
color: black;
list-style: none;
display: inline;
opacity: .7;
text-decoration: none;
}
解决方案
这个块:
<header>
<div id="header">
<h1 class="title">brookfield corp</h1>
<nav class="top-nav">
<ul>
<a href="#recent"><li>recent</li></a>
<a href="#samples"><li>samples</li></a>
</ul>
</nav>
</div>
</header>
需要搬进去
<body> </body>
然后你可以继续,在结束</body>
标签之前,使用<div id="body">
或类似的,跟随你的<header></header>
块。
推荐阅读
- python - 在 Python 中循环列并为文件中的每一列写入输出
- java - 是否有任何功能可以在整个脚本执行过程中将 Firefox 浏览器缩放级别设置为某个特定百分比?
- ios - 如何在没有抗锯齿的情况下调整 UIImage 的大小?
- angularjs - 控制器函数未在 Angular 模块 md-data-table 中调用
- android - 几个月前用旧应用和新应用转载:Crashlytics 没有报告旧应用中的崩溃或注册我的新应用
- android - VS2017 Xamarin android模拟器启动无法连接
- angular - 从firebase存储链接获取css中的字体?
- mysql - 在mysql中分组时从状态中获取学生结果
- ios - 动画后计算uiview的高度
- php - 更新查询正在更新每个新值并从数据库中删除以前更新的值