像这样:
> DEMO
码:
<!-- Fixed navbar --> <div role="navigation"> <div > <div > <button type="button" data-toggle="collapse" data-target=".navbar-collapse"> <span >Toggle navigation</span> <span ></span> <span ></span> <span ></span> </button> <a href="#">Project name</a> </div> <div > <ul > <li ><a href="#">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> </ul> </div><!--/.nav-collapse --> </div> </div> <div > <!-- Main component for a primary marketing message or call to action --> <div > <h1>Navbar example</h1> <p>This example is a quick exercise to illustrate how the default,static and fixed to top navbar work. It includes the responsive CSS and HTML,so it also adapts to your vIEwport and device.</p> <p>To see the difference between static and fixed top navbars,just scroll.</p> <p> <a href="../../components/#navbar" role="button">VIEw navbar docs »</a> </p> </div> </div> <!-- /container -->解决方法 这是一种在不添加任何额外标记的情况下执行此 *** 作的方法,但您确实需要为每个锚链接添加唯一的类.
CSS:
.navbar-default .navbar-nav>.active>a:before,.navbar-nav>li>a:before { background-repeat: no-repeat; background-position: 0 top; content: ""; display: inline-block; height: 29px; margin-right: 10px; vertical-align: mIDdle; wIDth: 29px;}.navbar-default .navbar-nav>.active>a.home:before,.navbar-nav>li>a.home:before { background-image: url('https://dl.dropBoxusercontent.com/sh/0be3c7ub4245kd6/18Xnfucw14/home.png'); }.navbar-default .navbar-nav>.active>a.about:before,.navbar-nav>li>a.about:before { background-image: url('https://dl.dropBoxusercontent.com/sh/0be3c7ub4245kd6/DhXiON5YiL/kveld.png'); }.navbar-default .navbar-nav>.active>a.contact:before,.navbar-nav>li>a.contact:before { background-image: url('https://dl.dropBoxusercontent.com/sh/0be3c7ub4245kd6/_fIDqgglaS/sol.png'); }
您可以在此处查看结果:http://jsfiddle.net/2WvpV/
你需要玩边距和填充.此外,这并不完美,因为您应该使用相对大小而不是像素.
总结以上是内存溢出为你收集整理的html – 如何在bootstrap导航栏中添加自己的图标全部内容,希望文章能够帮你解决html – 如何在bootstrap导航栏中添加自己的图标所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)