html - 我试图弄清楚如何让 div *topnav* 背景颜色适合页面宽度
问题描述
我试图弄清楚如何让 divtopnav
背景颜色从一边到另一边适应页面宽度而没有间隙。我希望你明白我的意思。如果您需要更多信息,请告诉我。显示差距的页面:
HTML 和 CSS 代码:
body {background-color: burlywood;}
#heading1{position: relative; text-align: center; top: 50px;}
#topnav{background-color: chocolate;
font-size: 30px;
text-align: center;
overflow: hidden;
position: relative;
word-spacing: 70px;
width: 100%; height: 100%;
bottom: 80px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="main.css">
<title></title>
</head>
<body>
<h1 id="heading1">Hello World</h1>
<div id="topnav">
<nav>
<a href="#"> About</a>
<a href="#"> sales</a>
<a href="#"> cart</a>
<a href="#"> home</a>
</ul>
</nav>
</div>
</body>
</html>
解决方案
穿上 body { padding:0; margin:0; }
风格
推荐阅读
- c++ - 使用 Tensorflow 的 C++ ABI 兼容性问题
- angular - 更改路由并将数据传递给另一个组件
- angular - 在构造函数中获取 Ionic 4 存储令牌值的解决方案是什么,例如在运行时将令牌设置为 http 标头?
- oauth - eBay OAuth 无法获取令牌
- mysql - MySql 服务器不是从命令提示符启动的
- google-cloud-platform - 所需的复合索引不存在,但在 index.yaml 中定义
- java - Kafka Consumer 输出过多的 DEBUG 语句
- azure - 如何在 Azure cosmos DB 中使用双引号保存数据
- c++ - 使用 sftp_open() 在 C++ 中使用 SFTP libssh 将文件从本地复制到远程时,文件返回 NULL 值
- bootloader - 如何从保护模式(或 C 代码)调用 PXE API?