如何将导航链接到右边的同时,将文本放在徽标旁边?
这是CSS的新手,我一直在从事一个练习项目,但无法做标题所说的。
我尝试了我在许多视频中看到的边缘权利:自动方法,它起作用,但它仅以标题为中心。
这是一些代码:
.logo {
cursor: pointer;
margin-right: auto;
margin-left: 1.5rem;
height: 3rem;
width: auto;
}
.title {
text-transform: capitalize;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 1.8rem;
font-weight: bold;
margin-right: auto;
}
header {
position: fixed;
z-index: 100;
width: 100%;
height: 4rem;
display: flex;
justify-content: flex-end;
align-items: center;
}
.nav_links {
list-style: none;
}
.nav_links li {
display: inline-block;
padding: 0 1.5rem 0 1rem;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 1.2rem;
}
<header>
<img class="logo" src="./Images/ic-logo.svg" alt="logo">
<div class="title">
<span class="title1">COLMAR</span>
<span class="title2">ACADEMY</span>
</div>
<nav>
<ul class="nav_links">
<li><a href="#">On Campus</a></li>
<li><a href="#">Online</a></li>
<li><a href="#">For companies</a></li>
<li><a href="#">Sign in</a></li>
</ul>
</nav>
</header>
我试图将标题移到徽标旁边,同时将导航栏链接到右侧。
任何帮助/指针都非常感谢。
This I'm new to CSS and I have been working on a practice project, but have not been able to do what title says.
I have tried the margin-right: auto method that I've seen in numerous videos and it works, but it only centers the title.
Here's some of the code:
.logo {
cursor: pointer;
margin-right: auto;
margin-left: 1.5rem;
height: 3rem;
width: auto;
}
.title {
text-transform: capitalize;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 1.8rem;
font-weight: bold;
margin-right: auto;
}
header {
position: fixed;
z-index: 100;
width: 100%;
height: 4rem;
display: flex;
justify-content: flex-end;
align-items: center;
}
.nav_links {
list-style: none;
}
.nav_links li {
display: inline-block;
padding: 0 1.5rem 0 1rem;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 1.2rem;
}
<header>
<img class="logo" src="./Images/ic-logo.svg" alt="logo">
<div class="title">
<span class="title1">COLMAR</span>
<span class="title2">ACADEMY</span>
</div>
<nav>
<ul class="nav_links">
<li><a href="#">On Campus</a></li>
<li><a href="#">Online</a></li>
<li><a href="#">For companies</a></li>
<li><a href="#">Sign in</a></li>
</ul>
</nav>
</header>
I'm trying to move the title next to the logo, while keeping the nav bar links to the right.
Any help/pointers are really appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这样做:
合理性:flex-end;
rain> rain-right:auto
。标题具有保证权利:auto;
阅读内联注释。
Do this:
justify-content: flex-end;
margin-right:auto
either. It is enoug that the title hasmargin-right: auto;
Read the inline comments.
不确定您在这里要做什么,图纸或表示形式将特别有用。但是我有两种可以用来解决此问题的方法。
制作一个将弹性盒像这样包裹徽标的弹性盒:
并使用导航栏做同样的事情:)
Not sure what you are trying to do here and a drawing or a representation would be particularly helpful. But I've got two ways that you can use to fix this.
Make a flex box that will wrap the logo like so:
And do the same thing with your navigation bar :)
使用您的HTML结构,您可以使用下面的CSS完成此操作。我剥离了您的样式,因此您只能看到完成您要求的准确的需要的内容。
Using your HTML structure you can accomplish this with the css below. I stripped away your styling so you can see only what is needed to accomplish exactly what you are asking for.