简体   繁体   English

将单词 Left Right 和 Center 对齐在同一行

[英]Align words Left Right and Center on the same line

I'm trying to make this nav but I don't know how to make all the words fit with one in the center, left and right我正在尝试制作此导航,但我不知道如何使所有单词都适合居中、左侧和右侧

<nav class="barBox" target="_blank">
<a href="#" class="bar"><font color="lime"><b>Home</b></font></a> 
<a href="#" class="bar"><font color="lime"><b>Forums</b></font></a> 
<a href="#" class="bar"><font color="lime"><b>Store</b></font></a>
</nav>

that's my code that I'm trying to make all on one line while the home is on the left, forums is in the center, store is on the right.这是我的代码,我试图将所有内容放在一条线上,而家在左侧,论坛在中心,商店在右侧。 All on the same line.都在同一条线上。

You could use positioning.你可以使用定位。 This is just one possible solution.这只是一种可能的解决方案。

 .barBox { width: 100%; position: relative; text-align: center; } .barBox a { color: #fff; background: #aaa; padding: 5px 10px; display: inline-block; font-weight: bold; text-decoration: none; } .barBox a:first-child { position: absolute; left:0; } .barBox a:last-child { position: absolute; right:0; }
 <nav class="barBox" target="_blank"> <a href="#" class="bar">Home</a> <a href="#" class="bar">Forums</a> <a href="#" class="bar">Store</a> </nav>

Note I removed the font and b tags.... they have been deprecated for years now.请注意,我删除了fontb标签……它们已被弃用多年。

Does this help you at all?这对你有帮助吗?

used:用过的:

float: left //left
margin: 0 auto; //center
right: 10px //push it to the right but can still see it

A little hacky but gets the job done有点笨拙,但可以完成工作

https://jsfiddle.net/t20jjjz7/1/ https://jsfiddle.net/t20jjjz7/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM