导航栏的文本对齐方式

huangapple go评论65阅读模式
英文:

Text alignment for navigation bar

问题

我正在按照教程操作,并尝试改变一些内容以进行实验,创建自己的东西。我知道我会到达一个我想要不同于教程的地方。在教程中,导航链接位于右侧。我希望它们更加居中,但仍然在右侧,以免挤占标题/标志。

我已经注释了一些行,更改了不同方面的大小,进行了研究,还进行了简单的实验。我知道答案会很简单,但我需要一些指导。我应该如何修复我的代码?

英文:

I am following a tutorial and then changing what I can to experiment and create something of my own. I knew I would get to a point where I wanted something different that what was in the tutorial.In the tutorial the nav link are aligned to the right. I am wanting them more center but still to the right so it doesn't crowd the title/logo.
I have commented lines out, changed sizes of different aspects, researched, and simply experimented. I know the answer is going to be stupid simple yet I could use some guidance. How should I fix my code?

css image

html image

答案1

得分: 0

在CSS文件中,你可以将头部类(.header)的 justify-content 更改为:

.header{
  justify-content: space-around;
 }

这样,头部标签内的元素会更加紧凑在一起,但仍然保留一些间距;尝试不同的 justify-content 值,如 centerspace-evenly,看看哪个适合你。

另一种方法是更改导航栏类(navbar)的 margin-left 值;将其设置为小于20px的值,使其向左移动一点。

在编程之路上祝你好运!

英文:

In the CSS file, you can change the justify-content of the header class to be:

.header{
  justify-content: space-around;
 }

this way the elements inside the header tag get more squished together but still have some space between them; experiment with different values of justify-content like center or space-evenly to see what works for you.

Another approach is to change the margin-left value of the navbar class; set to something less than 20px for it to move to the left a bit more.

Also good luck on your coding journey!

huangapple
  • 本文由 发表于 2023年7月13日 00:42:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76672803.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定