【发布时间】:2017-08-27 13:16:22
【问题描述】:
我已经制作了一个导航标题(你怎么称呼它),我希望在它的中间添加一些文本。
它基本上是一个黑色条,右侧有一些导航按钮(例如主页、关于我们、信息、图库...),左侧有一个徽标,现在我想在该条中间添加一些文本。我无法让它工作。
这是我到目前为止的代码。
/* Global settings */
* {
font-family: Roboto;
padding: 0;
margin: 0;
}
a {
text-decoration: none;
}
/* Header settings */
.header {
height: 50px;
width: 100%;
background-color: #212121;
position: fixed;
text-align: center;
}
.header ul {
height: 100%;
float: right;
position: relative;
right: 50px;
}
.header li {
display: inline-block;
height: 100%;
width: 75px;
text-align: center;
}
.header li:hover {
background-color: #616161;
}
.header a {
display: block;
color: #FAFAFA;
height: 100%;
line-height: 50px;
border: 1px solid orange;
}
.header img {
height: 100%;
color: #FAFAFA;
float: left;
}
.header h1 {
color: #FAFAFA;
Line-height: 50px;
display: inline-block;
}
<body>
<div class="header">
<h1>The text I want to be centered</h1>
<ul>
<li><a href="">Home</a></li>
<li><a href="">Info</a></li>
<li><a href="">Contact</a></li>
<li><a href="">About</a></li>
</ul>
<img src="" alt="Logo" />
</div>
</body>
【问题讨论】:
标签: html css element center centering