基础6 - 顶栏|如何在较小的设备上保留徽标?

时间:2016-05-11 13:03:09

标签: html css navigation zurb-foundation zurb-foundation-6

我尝试创建一个带有徽标,左侧菜单和右侧菜单的响应式顶栏。在移动设备上,我希望水平菜单成为“汉堡包图标”下的垂直菜单。

我希望徽标始终可见。适用于汉堡图标左侧的移动设备。还添加图标。

我查看了Zurb的例子,但我不希望logo / site-title进入较小屏幕的汉堡包菜单。

<div class="title-bar" data-responsive-toggle="main-menu" data-hide-for="medium">
  <button class="menu-icon" type="button" data-toggle></button>
</div>
<div class="top-bar">
    <li><img src="" > </li>
<div  id="main-menu">
  <div class="top-bar-left">

    <ul class="menu vertical medium-horizontal" data-responsive-menu="drilldown medium-dropdown">
          <li><a href="#">Albums</a></li>
          <li><a href="#">Music</a></li>
            <li><input type="search" placeholder="Search"></li>
    </ul>
  </div>
  <div class="top-bar-right">
    <ul class="dropdown vertical medium-horizontal menu">
      <li><a href="#">Contact</a></li>
      <li><a href="#">Logout</a></li>
    </ul>
  </div>
</div>
</div>
</div>

我想达到以下结果(使用bootstrap完成)

enter image description here enter image description here

2 个答案:

答案 0 :(得分:1)

在这种情况下,您可以使小屏幕中的图像不同(如果需要,可以更小)。 Foundation 6文档不是很好,所以这里是一个非常好的代码实现。请务必包含酒吧的背景颜色。没必要额外的css。

    <div class="title-bar" style="width:100%;background-color: #262626;">
        <div class="title-bar-left hide-for-medium">
            <span class="title-bar-title"><img src="http://placehold.it/80x40?text=Viberr" ></span>
            <button data-responsive-toggle="responsive-menu" class="menu-icon" type="button" ></button>
        </div>

        <div id="responsive-menu" >
            <div class="top-bar-title">
                <img src="http://placehold.it/80x40?text=Viberr" >
            </div>

            <div class="top-bar-left">
                <ul class="menu vertical medium-horizontal" data-responsive-menu="drilldown medium-dropdown">
                    <li><a href="#">Albums</a></li>
                    <li><a href="#">Music</a></li>
                    <li><input type="search" placeholder="Search"></li>
                </ul>
            </div>

            <div class="top-bar-right">
                <ul class="dropdown vertical medium-horizontal menu">
                    <li><a href="#">Contact</a></li>
                    <li><a href="#">Logout</a></li>
                </ul>
            </div>
        </div>

    </div>

答案 1 :(得分:0)

你需要为此添加一点CSS。我修改了默认的顶栏示例。

HTML

<div class="top-bar stacked-for-small">
  <div class="top-bar-title">
    <span data-responsive-toggle="responsive-menu" data-hide-for="medium">
      <button class="menu-icon dark" type="button" data-toggle></button>
    </span>
    <strong>Site Title</strong>
  </div>
  <div id="responsive-menu">
    <div class="top-bar-left">
      <ul class="dropdown menu" data-dropdown-menu>
        <li><a href="#">One</a></li>
        <li><a href="#">Two</a></li>
        <li><input type="search" placeholder="Search">
          <button type="button" class="button">Search</button></li>
      </ul>
    </div>
    <div class="top-bar-right">
      <ul class="menu">
        <li><a href="#">One</a></li>
        <li><a href="#">Two</a></li>
      </ul>
    </div>
  </div>
</div>

CSS

.menu>li {
    display: block;
}
.top-bar input {
    float:left;
}
.top-bar-title{
  float:none;
}
.top-bar-title span{
  float:right;
}
@media (min-width:640px){
  .menu>li {
      display: table-cell;
  }
  .top-bar-title{
    float: left;
  }
}

请参阅CodePen示例。 http://codepen.io/shoaibik/pen/wGORZY