flexbox navigation w / logo float&边界问题

时间:2015-02-21 11:13:56

标签: html css navigation css-float flexbox

我试图找出如何在我的flexbox导航中添加徽标。我想让徽标漂浮在左边。还尝试在链接悬停状态下使用边框底部,但它似乎是向下推动条的高度以及使用边框而不仅仅是文本的整个li。 任何帮助!



#nav {
    border-bottom: 5px solid #BF2B36;
}
.navigation {
  list-style: none;
  margin: 0; 
  background: #333333;
  position: relative;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-flow: row wrap;
  justify-content: flex-end;
  z-index: 2000;
  font-family: 'BabasNeueBold';
  font-size:24px;
  letter-spacing:2px;
  line-height:80px;
}

.logo {
  background:red;
	width:200px;
    height:50px;
	padding-top:10px;
  float:left;
}

.navigation a, .navigation a:active, .navigation a:visited {
  text-decoration: none;
  display: block;
  padding:0px 15px 0px 15px;
  color: #FFF;
  letter-spacing:2px;
}

.navigation a:hover {
	color: #BF2B36;
  border-bottom:2px solid #BF2B36;
}


@media all and (max-width: 800px) {
  .navigation {
    justify-content: space-around;
  }
}

@media all and (max-width: 600px) {
  .navigation {
    -webkit-flex-flow: column wrap;
    flex-flow: column wrap;
    padding: 0;
  }
  
  .navigation a { 
    text-align: center; 
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,0.3); 
  }
  
  .navigation a:hover {
	color: #BF2B36;
    border-bottom:2px solid #BF2B36;
}

  
}

<div id="nav">
<ul class="navigation">
  <li><div class="logo"></div></li>
  <li><a href="#">Home</a></li>
  <li><a href="#">About</a></li>
  <li><a href="#">Products</a></li>
  <li><a href="#">Contact</a></li>
</ul>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

您只需添加 border-bottom:2px solid transparent; 用于导航...

#nav {
    border-bottom: 5px solid #BF2B36;
}
.navigation {
  list-style: none;
  margin: 0; 
  background: #333333;
  position: relative;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-flow: row wrap;
  justify-content: flex-end;
  z-index: 2000;
  font-family: 'BabasNeueBold';
  font-size:24px;
  letter-spacing:2px;
  line-height:80px;
}

.logo {
  background:red;
	width:200px;
    height:50px;
	padding-top:10px;
  float:left;
}

.navigation a, .navigation a:active, .navigation a:visited {
  text-decoration: none;
  display: block;
  padding:0px 15px 0px 15px;
  color: #FFF;
  letter-spacing:2px;
 border-bottom:2px solid transparent;
}

.navigation a:hover {
	color: #BF2B36;
  border-bottom:2px solid #BF2B36;
}


@media all and (max-width: 800px) {
  .navigation {
    justify-content: space-around;
  }
}

@media all and (max-width: 600px) {
  .navigation {
    -webkit-flex-flow: column wrap;
    flex-flow: column wrap;
    padding: 0;
  }
  
  .navigation a { 
    text-align: center; 
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,0.3); 
  }
  
  .navigation a:hover {
	color: #BF2B36;
    border-bottom:2px solid #BF2B36;
}

  
}
<div id="nav">
<ul class="navigation">
  <li><div class="logo"></div></li>
  <li><a href="#">Home</a></li>
  <li><a href="#">About</a></li>
  <li><a href="#">Products</a></li>
  <li><a href="#">Contact</a></li>
</ul>
</div>