使用Bootstrap使搜索输入宽度为100%

时间:2016-03-26 15:23:15

标签: html css forms twitter-bootstrap

我试图在屏幕的重新调整大小(使用 @media(max-width:1200px))时使搜索输入宽度为100%,但它无法正常工作。 问题:

enter image description here

它应该如何(我可以使用像素的精确宽度值来正确使用,但我不认为我做对了):

enter image description here

index.html 文件:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MONI BAU</title>
<link rel="icon" href="Fotot/icon.png">
<link href="Css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="Css/style.css">
</head>
<body>
<div class="container">
<nav class="navbar navbar-default">

        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mainNavBar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a href="#" class="navbar-brand"><img src="Fotot/logo.png" width="200px"></a>
        </div>
        <div class="collapse navbar-collapse" id="mainNavBar">
            <div class="paddingSearch navbar-right">
                <form class="navbar-form" role="search">
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="Kërko" name="q">
                            <div class="input-group-btn">
                                <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
                            </div>
                    </div>
                </form>
            </div>              
            <ul class="nav navbar-nav navbar-right paddingSearch">
                <li><a href="#"><i class="glyphicon glyphicon-home">     </i>Kryefaqja</a></li>
                <li><a href="#"><i class="glyphicon glyphicon-wrench"></i>Produktet</a></li>
                <li><a href="#"><i class="glyphicon glyphicon-envelope"></i>Kontakt</a></li>
                <li><a href="#"><i class="glyphicon glyphicon-user"></i>Për Ne</a></li>
            </ul>
        </div>
</nav>
</div>

<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<script type="text/javascript" src="JS/bootstrap.min.js"></script>
</body>
</html>

和我的自定义 style.css

body{
background-image: url(../Fotot/background.png);
margin: 0;
padding: 0;
font-family: Century Gothic,CenturyGothic,AppleGothic,sans-serif; 
}
.navbar-brand {
height: 80px;
}
.paddingSearch
{   
padding-top: 15px;
padding-bottom:15px;
margin: 0;  
color: #1a0000;  
font-size: 12pt;
}
.paddingSearch i{
color: black;
width: 20px;
}   
.navbar-toggle {
padding: 10px;
margin: 25px 15px 25px 0;
}
.navbar-brand {
display: flex;
align-items: center;
}

@media (max-width: 1200px) {
.navbar-header {
    float: none;
}
.navbar-left,.navbar-right {
    float: none !important;
}
.navbar-toggle {
    display: block;
}
.navbar-collapse {
    border-top: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-fixed-top {
    top: 0;
    border-width: 0 0 1px;
}
.navbar-collapse.collapse {
    display: none!important;
}
.navbar-nav {
    float: none!important;
    margin-top: 7.5px;
}
.navbar-nav>li {
    float: none;
}
.navbar-nav>li>a {
    padding-top: 10px;
    padding-bottom: 10px;
}
.collapse.in{
    display:block !important;
}
.navbar-nav .open .dropdown-menu {
   position: static;
   float: none;
   width: auto;
   margin-top: 0;
   background-color: transparent;
   border: 0;
   -webkit-box-shadow: none;
   box-shadow: none;
}
}

1 个答案:

答案 0 :(得分:-1)

将媒体查询更改为@media(min-width:1200px)而不是max-width。