[英]How to display title in the center of navigation bar without using padding-left
I want to center the "title123" div element without using padding-left.我想在不使用 padding-left 的情况下将“title123”div 元素居中。 I have tried fidgeting around with the css as you can see below but the title remains on the left end of the navigation bar.
正如您在下面看到的那样,我尝试过使用 css,但标题仍保留在导航栏的左端。 Any help/advice would be appreciated!
任何帮助/建议将不胜感激! Code below:
代码如下:
<nav class="navbar fixed-top navbar-expand-lg" style="background-color:black">
<div class="title123">
Title
</div>
</nav>
.title123 {
font: bold;
font-family: "Arial Black", Gadget, sans-serif;
font-size: 28px;
color: ghostwhite;
display: block;
text-align: center;
float:right;
vertical-align: top;
}
.navbar {
display: block;
text-align:center;
}
.title123 {
font: bold;
font-family: "Arial Black", Gadget, sans-serif;
font-size: 28px;
color: ghostwhite;
display: inline-block;
text-align: center;
}
.navbar { display: flex; .navbar { 显示: flex; justify-content: center;}
对齐内容:中心;}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.