我刚刚开始我的网站,我目前正在工作的标题/导航栏。我让它看上去像我想要的,但是有一件事我无法弄清楚,就是如何在标题中垂直地将徽标和超链接放在中间?
以下是我的HTML:
<body>
<div class="header">
<div class="container">
<div class="logo">
<h1><a href="index.html"><img src="logo.png"></a></h1>
</div>
<div class="nav">
<ul>
<li><a href="index.html">ABOUT ME</a></li>
<li><a href="">PROJECTS</a></li>
<li><a href="">CONTACT</a></li>
</ul>
</div>
</div>
</div>
<div class="content">
<p>
</p>
</div>
</body>和CSS:
body {
font-family: 'Nunito', sans-serif;
width: 100%;
margin: auto;
background: #F4F4F4;
}
a {
text-decoration: none;
color: #fff;
}
img {
max-width: 100%;
}
/**********************************
HEADING/NAVIGATION
***********************************/
li {
list-style: none;
float: left;
margin-left: 25px;
padding-top: 10px;
}
.container {
width: 960px;
margin: 0 auto;
}
.header {
background: #5BBB9B;
width: 100%;
height: 200px;
top: 0;
position: fixed;
border-bottom: 1px solid black;
}
.logo {
float: left;
}
.nav {
float: right;
}我试过使用vertical-alignment: middle;,但是这不起作用。
有人有什么建议吗?
发布于 2015-11-12 22:52:48
使用
display:table;
height:100%;为父母和
display: table-cell;
text-align: center;
vertical-align: middle;https://stackoverflow.com/questions/33682887
复制相似问题