如何使顶部的导航条基于图像位置居中,而不是整个导航栏的块?将一个元素置于nav中间
我之所以想到这个,是因为如果某人有一个长名字,那么nav就不会看起来居中。我想知道做出相对的位置,但我不确定这是否会起作用,或者使用浮动或不是。
.profileinfo {
padding: 0 10px;
float: left;
}
.profileinfo:nth-child(2) img {
align: middle;
width: 60px;
height: 60px;
border-radius: 50%;
}
.profileinfo:first-child {
border-right: 1px solid silver;
}
.profileinfo:last-child {
border-left: 1px solid silver;
}
.profileinfo:last-child,
.profileinfo:first-child {
margin-top: 20px;
}
#container {
height: 80px;
width: 300px;
margin: 10px auto;
padding: 0;
}
ul {
list-style-type: none;
}
<ul id="container">
<li class="profileinfo">Ashley Siwiec</li>
<li class="profileinfo">
<a href="/accounts/profile/">
<img src="//dummyimage.com/60">
</a>
</li>
<li class="profileinfo">C: 175</li>
</ul>
你有中间'img'的常维? –