在导航图标css下包装文本。

时间:2020-12-11 22:21:37

this is my first post so please be gentle.

这是我的第一个帖子,请温柔点。

I'm trying to create a nav bar using html5 and css and it needs to work with ie8. I have managed to nearly everything i need to done but one thing. i cant make my icons and text to centre align correctly for each navigation button

我正在尝试用html5和css创建一个导航条,它需要和ie8一起工作。我已经完成了几乎所有我需要做的事情,但有一件事。我不能让我的图标和文字正确地对齐每个导航按钮。

CSS

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

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>

1 个解决方案

#1


0  

here is your updated and working fiddle :
http://jsfiddle.net/553n0udw/1/ Updated Fiddle

这里是您最新的和工作的小提琴:http://jsfiddle.net/553n0udw/1/更新的小提琴。

i am using glyph-icon, you can use anything you just need to make a class for you custom icon and give it a background url. follow the bootstrap icon rules that will help a lot.

我正在使用符号图标,你可以使用任何你只需要为你定制图标的类,并给它一个背景url。跟随引导图标规则,将会有很大帮助。

#1


0  

here is your updated and working fiddle :
http://jsfiddle.net/553n0udw/1/ Updated Fiddle

这里是您最新的和工作的小提琴:http://jsfiddle.net/553n0udw/1/更新的小提琴。

i am using glyph-icon, you can use anything you just need to make a class for you custom icon and give it a background url. follow the bootstrap icon rules that will help a lot.

我正在使用符号图标,你可以使用任何你只需要为你定制图标的类,并给它一个背景url。跟随引导图标规则,将会有很大帮助。