【发布时间】:2018-09-15 20:57:01
【问题描述】:
我想将“登录”项向右对齐。 我对 HTML 和 CSS 很陌生。我什至不知道这是否是创建水平菜单栏的正确方法。 像这样:How I want it to be
这是我的代码:
HTML:
@import url("FONTS/stylesheet.css");
body {
font-family: 'Roboto', sans-serif;
}
.topnav {
background-color: #333;
overflow: hidden;
}
.topnav a {
display: inline-block;
color: #f2f2f2;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background: #ddd;
color: black;
}
/* Add a color to the active/current link */
.topnav a.active {
background-color: #4CAF50;
color: white;
}
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="css/style1.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<body>
<div class="topnav">
<a class="active" href="#home">Home</a>
<a href="#projects">Projects</a>
<a href="#contact">Contact</a>
<a class="loginnav" href="#login">Login</a>
</div>
</body>
</html>
我需要改变什么? 非常感谢!
【问题讨论】:
标签: html css alignment text-align