如何将导航栏菜单放置在徽标下方?

时间:2019-02-13 11:00:32

标签: html css twitter-bootstrap twitter-bootstrap-3 navbar

我已经使用自定义CSS和bootstrap类名称构建了此标头。我已经尝试过z-indexfloat: initial属性。预先感谢

.branding-preview {
    height: 75px;
    margin-left: 15px;
    margin-right: 15px;
    background-color: #0071bb;
}

.branding-logo {
    float: left;
    height: 50px;
    font-size: 18px;
    padding: 15px 15px;
}

.branding-logo img {
    width: 300px;
    height: 50px;
}

.branding-powered-by-logo {
    float: right;
    height: 50px;
    color: white;
    font-size: 15px;
    padding: 2px 10px;
}

.preview-menu {
    margin: 30px 0 0 0;
}

.preview-menu > li > a {
    margin: 0 3px;
    color: white;
    text-transform: uppercase;
    border-bottom: solid 1px transparent;
    background-color: transparent !important;
}
<div class="branding-preview">
	<div class="branding-logo">
		<img id="branding-logo" src="/path/to/logo">
	</div>
	<div class="branding-powered-by-logo">
		<span>Powered By</span>
		<img id="branding-powered-by-logo" src="/path/to/logo" height="30">
	</div>
	<ul class="navbar-nav navbar-right nav preview-menu">
		<li><a>Start</a></li>
		<li><a>Plan</a></li>
		<li><a>Manage</a></li>
		<li><a>Learn</a></li>
		<li><a>Admin</a></li>
	</ul>
</div>

这是我使用当前代码得到的结果, 实际结果:

enter image description here

这是我希望它将看起来像预期的结果:

enter image description here

2 个答案:

答案 0 :(得分:0)

我认为您只需要添加 position:absolute; right:0px; 进入您的.preview-menu类。

答案 1 :(得分:0)

没有所有css规则并不简单,但是概念是:创建一个向右浮动的包装器,并在其中创建2行,其中第一行用于branding-powered-by-logodisplay:block,第二行取决于实际的CSS,但可能无需修改即可使用。

如果您可以发布真实页面,我们可以为您提供更高的精确度。 希望对您有帮助。

.branding-preview {
    display:block;
    height: 75px;
    margin-left: 15px;
    margin-right: 15px;
    background-color: #0071bb;
}

.branding-logo {
    float: left;
    height: 50px;
    font-size: 18px;
    padding: 15px 15px;
}

.branding-logo img {
    width: 300px;
    height: 50px;
}

.branding-powered-by-logo {
    /* ADDED */
      display:block;
      text-align:right;
    
    height: 50px;
    color: white;
    font-size: 15px;
    padding: 2px 10px;
}

.preview-menu {
    margin: 0px 0 0 0;
}

.preview-menu > li > a {
    margin: 0 3px;
    color: white;
    text-transform: uppercase;
    border-bottom: solid 1px transparent;
    background-color: transparent !important;
}


/* ADDED */
.wrapper-logo-navbar {
  float: right;
}
.preview-menu > li {
  display: inline-block;
}
<div class="branding-preview">
	<div class="branding-logo">
		<img id="branding-logo" src="/path/to/logo">
	</div>
  
  <div class="wrapper-logo-navbar">
    <div class="branding-powered-by-logo">
      <span>Powered By</span>
      <img id="branding-powered-by-logo" src="https://cdn.pixabay.com/photo/2012/05/02/19/27/head-46086_960_720.png" height="30">
    </div>
    <ul class="navbar-nav navbar-right nav preview-menu">
      <li><a>Start</a></li>
      <li><a>Plan</a></li>
      <li><a>Manage</a></li>
      <!-- removed some elements for the rendering on StackOverflow -->
    </ul>
  </div>
</div>