image.png

  1. <header class="col-md-2">
  2. <div class="logo">
  3. <a href="#">
  4. <img src="images/logo.png" alt="">
  5. </a>
  6. </div>
  7. <div class="nav">
  8. <ul>
  9. <li><a href="#" class="glyphicon glyphicon-camera">生活馆</a></li>
  10. <li><a href="#" class="glyphicon glyphicon-picture">自然汇</a></li>
  11. <li><a href="#" class="glyphicon glyphicon-phone">科技潮</a></li>
  12. <li><a href="#" class="glyphicon glyphicon-gift">奇趣事</a></li>
  13. <li><a href="#" class="glyphicon glyphicon-glass">美食节</a></li>
  14. </ul>
  15. </div>
  16. </header>
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

header .nav ul {
  background-color: #eee;
  border-bottom: 1px solid #666;
}

header .nav ul li {
  padding-left: 30px;
}

header .nav ul li a {
  display: block;
  height: 50px;
  line-height: 50px;
  font-size: medium;
  color: #666;
}


header .nav ul li a::before {
  padding-right: 5px;
  vertical-align: middle;
}



header .nav ul li:hover {
  background-color: #fff;
}

header .nav ul li a:hover {
  color: #333;
}

图标插入

bootstrap组件里找
image.png复制类名

  • 生活馆

  • 谁用就给谁加上这个类
    实现原理是用了::before
    image.png
    所以通过 a::before 写样式可以改变图标的样式和位置

    header .nav ul li a::before {
    padding-right: 5px;
    vertical-align: middle;
    }