[英]Can't get my Navbar to align properly
Here is what my navbar looks like... 这是我的导航栏的样子...
I can't get the bell to sit just to the left of the profile picture.... 我不能让铃铛坐在个人资料图片的左侧。
Here is my HTML: 这是我的HTML:
<header>
<div class="navbar-top">
<div class="navbar-container">
<h1 class="navbar-heading pull-left">
<a class="tributr-logo" href="{{pathFor 'stream'}}">Tributr </a><small class="tributr-logo">(Private Beta)</small>
</h1>
<div class="navbar-heading pull-right">
<a style="color: #FFFFFF"><i class="fa fa-bell fa-2x"></i></a>
<div class="dropdown-toggle" type="button" data-toggle="dropdown">
<img class="navbar-photo" src="{{currentUser.profile.avatarURL}}" />
{{currentUser.profile.firstName}} {{currentUser.profile.lastName}}
<div class="settings pull-right"><i class="fa fa-sort-asc fa-2x"></i></div>
</div>
<ul class="dropdown-menu col-md-2">
<li><a href="{{pathFor 'profile'}}">Settings</a></li>
<li><a data-action="logout">Logout</a></li>
</ul>
</div>
</div>
</div>
</header>
Here is my CSS: 这是我的CSS:
/* Nav Bar */
.navbar-top {
height: 64px;
background-color: #772A75;
position:fixed;
width: 100%;
min-height: 64px;
top: 0;
left: 0;
z-index:1000;
box-shadow: 0px 2px 10px #888888;
}
.navbar-container {
padding: 0 20px;
color: #FFFFFF;
}
.navbar-heading {
margin-top: 10px;
}
.tributr-logo {
color: #FFFFFF;
}
.tributr-logo:hover {
color: #FFFFFF;
text-decoration: none;
}
/* Right side of navbar */
.navbar-photo {
border-style: solid;
border-width: 1px;
border-color: #DEE2EC;
border-radius: 100px;
height: 45px;
width: 45px;
margin-right: 10px;
}
.settings {
margin-top: -42px;
margin-left: 30px;
}
/* Drop down menus */
#app .dropdown-menu {
background-color: #772A75;
}
.dropdown-menu li {
padding: 10px;
}
#app .dropdown-menu > li > a {
color: #FFFFFF;
}
It's a bit hard to tell without a jsfiddle or gist set up to take a look, but there are a few things you can likely do to have the bell image and avatar align. 如果没有设置jsfiddle或gist来看一下,这很难说,但是您可以做一些事情来使钟形图像和头像对齐。 As Summea mentions above, you can try adding a
float
property to the bell. 正如Summea上面提到的,您可以尝试向钟声添加一个
float
属性。
Another likely option is setting display: inline-block;
另一个可能的选项是设置
display: inline-block;
on your dropdown-toggle
<div>
. 在
dropdown-toggle
<div>
。 Because the bell is an image/icon and has a default property of inline-block
, that should help them align. 因为铃铛是图像/图标,并且具有
inline-block
的默认属性,所以应该可以帮助它们对齐。
Tiny suggestion: replace <i>
with <img>
elements. 小建议:将
<i>
替换为<img>
元素。 I'd also recommend throwing the code onto a gist/fiddle - other people may be able to provide better answers than mine that way. 我还建议将代码放到要点/小提琴上,其他人可能比我提供更好的答案。 :)
:)
<div class="navbar-container">
<div class="something col-0">
<h1>
<a class="tributr-logo" href="{{pathFor 'stream'}}">Tributr </a><small class="tributr-logo">(Private Beta)</small>
</h1>
</div>
<div class="something col-1">
<a style="color: #FFFFFF"><i class="fa fa-bell fa-2x"></i></a>
</div>
<div class="something col-2">
<div class="dropdown-toggle" data-toggle="dropdown">
<img class="navbar-photo" src="{{currentUser.profile.avatarURL}}" />
{{currentUser.profile.firstName}} {{currentUser.profile.lastName}}
<div class="settings pull-right"><i class="fa fa-sort-asc fa-2x"></i></div>
</div>
</div>
<div class="something col-3">
<ul class="dropdown-menu col-md-2">
<li><a href="{{pathFor 'profile'}}">Settings</a></li>
<li><a data-action="logout">Logout</a></li>
</ul>
</div>
<div class="clear"></div>
</div>
then the style
<style>
.navbar-container {
margin:0;
padding:0;
height:
width:
}
.something {
float:left;
height:
}
.clear {
clear:both
}
.col-0 {
width:
}
.col-1 {
width:
}
.col-2 {
width:
}
.col-3 {
width:
}
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.