简体   繁体   English

响应式导航菜单引导

[英]Responsive navigation menu bootstrap

I am working on a bootstrap project and I have to create a navigation menu like this : 我正在进行引导项目,并且必须创建一个导航菜单, 如下所示

I used absolute position for it but it is not responsive when I scale it to smaller resolution (it becomes too small when I scale down). 我为它使用了绝对位置,但是当我将其缩放到较小的分辨率时它没有响应(当我按比例缩小时它变得太小)。 Is there any method to make a responsive navigation menu (like the image above)? 有什么方法可以制作响应式导航菜单(如上图所示)?

Here's my source: 这是我的资料来源:

<div id ="top" class="container">
    <div class="top-menu row">
        <ul class="top-menu-buttons col-lg-12 col-xs-12">
            <li class="col-lg-3 col-xs-3">
                <a href="#" class="top-menu-button menu-bt-active">
                    <img class="img-responsive" src="img/home-bt-enable.png">
                </a>
            </li>
            <li class="col-lg-3 col-xs-3">
                <a href="#" class="top-menu-button menu-bt-inactive">
                    <img class="img-responsive" src="img/deal-bt.png">
                </a>
            </li>
            <li class="col-lg-3 col-xs-3">
                <a href="#" class="top-menu-button menu-bt-inactive">
                    <img class="img-responsive" src="img/about-bt.png">
                </a>
            </li>
            <li class="col-lg-3 col-xs-3">
                <a href="#" class="top-menu-button menu-bt-inactive">
                    <img class="img-responsive" src="img/contact-bt.png">
                </a>
            </li>
        </ul>
    </div>
</div>

CSS: CSS:

.top-menu ul,
.top-menu li{
    display: inline-block;
}

.top-menu{
    padding-left: 170px;
    padding-right: 170px;
    padding-bottom: 0;
    bottom: 0;
    top:auto;
}

.top-menu-button{
    display: inline-block;
    position: absolute;

    width: 100%;
}

.menu-bt-active{
    top: 22px;

}

.menu-bt-inactive{
    top: 37px;

}
  <div class="nav navbar-default navbar-static-top">
    <div class="container-fluid">
        <button class="navbar-toggle" data-toggle="collapse" data-target=".navHeadCollapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>

        <div class="navbar-brand collapse navbar-collapse navHeadCollapse">
            <a href="#">
                <img id="img_navbar" src="img/home-bt-enable.png">
            </a>
            <a href="#">
                <img id="img_navbar" src="img/deal-bt.png">
            </a>
            <a href="#">
                <img id="img_navbar" src="img/about-bt.png">
            </a>
            <a href="#">
                <img id="img_navbar" src="img/contact-bt.png">
            </a>

            <div id="search"class="input-group">
                <input type="text" class="form-control" placeholder="Search">
                <span class="input-group-btn">
                    <button class="btn btn-default" type="button">
                        <span class="glyphicon glyphicon-search"></span>
                    </button>
                </span>
            </div>
        </div>
    </div>  
</div>

Try this CSS 试试这个CSS

#img_navbar
{
  margin-left: 3%;
  float: left;
  margin-bottom: 10;
  width:3%; 
  height:3%;
}


#search
{
  width:20%;float:right; 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM