html - 将导航按钮与文本对齐
问题描述
我正在开发一个移动第一页,我正在尝试将导航按钮与文本对齐,我想知道我是否做得正确。(忽略字体差异)这是我需要达到的结果:
这就是我所做的:
h1 {
font-family: "BebasNeue";
color: #016008;
text-shadow: 2px 2px 2px #000000;
font-size: 2rem;
}
#boot {
font-family: "BebasNeue";
color: #016008;
text-shadow: 2px 2px 2px #000000;
font-size: 3rem;
}
.navbutton {
border: solid 2px #000000;
border-radius: 15px;
color: #000000;
padding: 10px;
text-decoration: none;
margin: 10px;
float: right;
}
<header id="titleHeader">
<h1><span id="boot">BOOT</span>WORLD<a class="navbutton" href="#navbar">Menu</a></h1>
</header>
解决方案
您不能在 h1 标签内使用菜单导航按钮。我将它们分开,并将 flex 添加到标题容器以及一些样式到 Menu btn
body {
font-size: 16px;
}
h1 {
font-family: "BebasNeue";
color: #016008;
text-shadow: 2px 2px 2px #000000;
font-size: 2rem;
}
#boot {
font-family: "BebasNeue";
color: #016008;
text-shadow: 2px 2px 2px #000000;
font-size: 3rem;
}
.navbutton {
border: solid 3px #000000;
border-radius: 50px;
font-weight: 700;
font-size: 1.5rem;
color: #000000;
padding: 6px 20px;
text-decoration: none;
margin: 10px;
float: right;
}
#titleHeader {
display: flex;
justify-content: space-between;
align-items: center;
}
<body>
<header id="titleHeader">
<h1><span id="boot">BOOT</span>WORLD</h1> <a class="navbutton"
href="#navbar">Menu</a>
</header>
</body>
推荐阅读
- angular - 角度数据表错误加载数据
- react-native - 如何从不同的减速器更新状态?
- c - C 中动态内存分配的地址行为
- firebase - 使用 Firebase 控制台导入数据会触发太多 Firebase 函数
- android - 如何使用 Firebase Auth UI 登录按钮作为 onClickListener 的 id
- vbscript - 使用 FileSystemObject 检查网络文件夹是否存在不起作用
- inno-setup - 从 Inno Setup 中的 key=value 文本文件(不带部分)获取值?
- vb.net - 在 VB 中使用带有 MVC 的 API 下载文件
- php - Youtube 视频列表分页
- oracle - 我可以在 ORACLE 中使用这种语法吗?(SUM(CA.DEPT)=SUM(CA.RECEIVABLE)