这是我的第一篇文章所以请保持温和。
我正在尝试使用html5和css创建一个导航栏,它需要使用ie8。我已经成功完成了我需要做的一切,但有一件事。我无法使我的图标和文本在每个导航按钮中心正确对齐
CSS
.navbar-default .navbar-nav>.active>a:before,
.navbar-nav>li>a:before {
background-repeat: no-repeat;
background-position: 0 top;
content: "";
height: 40px;
width: 40px;
margin-right: 10px;
vertical-align: top;
background-color:transparent;
display:inline-block;
float:none;
}
.navbar-default .navbar-nav>.active>a.home:before,
.navbar-nav>li>a.dashboard:before { background-image: url('/VerificationServices/Static/Icons/dashboard.png');}
.navbar-default .navbar-nav>.active>a.about:before,
.navbar-nav>li>a.uploadscv:before { background-image: url('/VerificationServices/Static/Icons/UploadSCV.png'); }
.navbar-default .navbar-nav>.active>a.contact:before,
.navbar-nav>li>a.uploaddocs:before { background-image: url('/VerificationServices/Static/Icons/UploadDocs.png'); }
.navbar-default .navbar-nav>.active>a.contact:before,
.navbar-nav>li>a.viewrun:before { background-image: url('/VerificationServices/Static/Icons/viewrun.png'); }
.navbar-default .navbar-nav>.active>a.contact:before,
.navbar-nav>li>a.selfver:before { background-image: url('/VerificationServices/Static/Icons/selfver.png'); }
.navbar-default .navbar-nav>.active>a.contact:before,
.navbar-nav>li>a.selfver:hover { background-image: url('/VerificationServices/Static/Icons/dashboard.png'); }
HTML
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Norges Idrettshøgskole</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#" class="dashboard">Dashboard</a></li>
<li><a href="#about" class="uploadscv">Upload SCV File</a></li>
<li><a href="#contact" class="uploaddocs">Upload documents</a></li>
<li><a href="#contact" class="viewrun">View run results</a></li>
<li><a href="#contact" class="selfver">Self verification</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
答案 0 :(得分:0)
这是你更新和工作的小提琴:
http://jsfiddle.net/553n0udw/1/ Updated Fiddle
我正在使用字形图标,你可以使用你需要的任何东西为你自定义图标制作一个类并给它一个背景网址。遵循有用的bootstrap图标规则。