代码之家  ›  专栏  ›  技术社区  ›  user5005768Himadree

引导:如何正确地使这些元素响应

  •  2
  • user5005768Himadree  · 技术社区  · 9 年前

    我用Bootstrap设计了一个屏幕。我添加了一个输入 typehead 特征。但在添加后,响应性(例如最小化或最大化等上的大小调整)将变为非活动状态。

    这是我想要的照片示例: enter image description here

    但现在我得到的是:

    enter image description here

     
             $(document).ready(function(){
             	$('input.typeahead').typeahead({
             		name: 'accounts',
             		local: ['Person1', 'Person2', 'Person3', 'Person4', 'Person5', 'Person6', 'Person7']
             		
             	});
             });  
             .bs-example{
             //font-family: sans-serif;
             position: relative;
             margin: 100px;
             }
             .typeahead, .tt-query, .tt-hint {
             border: 2px solid #CCCCCC;
             border-radius: 8px;
             font-size: 12px;
             height: 30px;
             line-height: 30px;
             outline: medium none;
             padding: 8px 12px;
             width: 0px;
             }
             .typeahead {
             background-color: #FFFFFF;
             }
             .typeahead:focus {
             border: 2px solid #0097CF;
             }
             .tt-query {
             box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
             }
             .tt-hint {
             color: #999999;
             }
             .tt-dropdown-menu {
             background-color: #FFFFFF;
             border: 1px solid rgba(0, 0, 0, 0.2);
             border-radius: 8px;
             box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
             margin-top: 12px;
             padding: 8px 0;
             //width: 422px;
             }
             .tt-suggestion {
             font-size: 24px;
             line-height: 24px;
             padding: 3px 20px;
             }
             .tt-suggestion.tt-is-under-cursor {
             background-color: #0097CF;
             color: #FFFFFF;
             }
             .tt-suggestion p {
             margin: 0;
             }
        
    <!DOCTYPE html>
    <html lang="en">
       <head>
          <title>Test</title>
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    	  
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    	  <script src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/typeahead.min.js"></script>
          <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
              
          
    	  
          
       </head>
       <body >
          <div class="container"  >
             <div class="panel-group">
                <div class="panel panel-primary"  >
                   <div class="panel-heading" >
                      <h3 class="panel-title" style="text-align: center;">Test Responsive</h3>
                   </div>
                   <div class="panel-body">
                      <form class="form-horizontal" >
                         <div class="form-group">
                            <label class="control-label col-sm-3"  for="acode">Person</label>
                            <div class="col-sm-5" id = "empid" >
                               <div class="input-group ">                      
                                  <span class="input-group-addon"><i class="glyphicon glyphicon-user"  aria-hidden="true"></i></span>							    
                                  <input type="text" class="form-control typeahead tt-query" autocomplete="off" spellcheck="false" name="textemployeeid"  id="textemployeeid"  placeholder="Enter"> 
                                  <span class="input-group-btn">
                                  <button type="button" id="search" class="btn btn-xs btn-danger" style="background-color:red;">
                                  <span class="input-group-addon"><i class="glyphicon glyphicon-search "  aria-hidden="true"></i></span>
                                  </button>    
                                  </span>
                               </div>
                            </div>
                         </div>
                      </form>
                   </div>
                </div>
             </div>
          </div>
       </body>
    </html>

    请帮我解决这个问题。谢谢

    1 回复  |  直到 9 年前
        1
  •  2
  •   Community CDub    8 年前

    您需要将此类添加到css中:

    编辑时间: 我添加了 display:block !important; 到班级

    .twitter-typeahead {
                      width: 100%;
                      display:block !important;
             }
    

    顺便说一句,它以前已经回答过:

    Typeahead problems with Bootstrap 3.0 RC1

    希望这能有所帮助。

    $(document).ready(function(){
             	$('input.typeahead').typeahead({
             		name: 'accounts',
             		local: ['Person1', 'Person2', 'Person3', 'Person4', 'Person5', 'Person6', 'Person7']
             		
             	});
             });
    .bs-example{
             //font-family: sans-serif;
             position: relative;
             margin: 100px;
             }
             .typeahead, .tt-query, .tt-hint {
             border: 2px solid #CCCCCC;
             border-radius: 8px;
             font-size: 12px;
             height: 30px;
             line-height: 30px;
             outline: medium none;
             padding: 8px 12px;
             width: 0px;
             }
             .typeahead {
             background-color: #FFFFFF;
             }
             .typeahead:focus {
             border: 2px solid #0097CF;
             }
             .tt-query {
             box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
             }
             .tt-hint {
             color: #999999;
             }
             .tt-dropdown-menu {
             background-color: #FFFFFF;
             border: 1px solid rgba(0, 0, 0, 0.2);
             border-radius: 8px;
             box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
             margin-top: 12px;
             padding: 8px 0;
             //width: 422px;
             }
             .tt-suggestion {
             font-size: 24px;
             line-height: 24px;
             padding: 3px 20px;
             }
             .tt-suggestion.tt-is-under-cursor {
             background-color: #0097CF;
             color: #FFFFFF;
             }
             .tt-suggestion p {
             margin: 0;
             }
            .twitter-typeahead {
                      width: 100%;
                      display:block !important;
             }
    <!DOCTYPE html>
    <html lang="en">
       <head>
          <title>Test</title>
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    	  
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    	  <script src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/typeahead.min.js"></script>
          <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
              
          
    	  
          
       </head>
       <body >
          <div class="container"  >
             <div class="panel-group">
                <div class="panel panel-primary"  >
                   <div class="panel-heading" >
                      <h3 class="panel-title" style="text-align: center;">Test Responsive</h3>
                   </div>
                   <div class="panel-body">
                      <form class="form-horizontal" >
                         <div class="form-group">
                            <label class="control-label col-sm-3"  for="acode">Person</label>
                            <div class="col-sm-5" id = "empid" >
                               <div class="input-group ">                      
                                  <span class="input-group-addon"><i class="glyphicon glyphicon-user"  aria-hidden="true"></i></span>							    
                                  <input type="text" class="form-control typeahead tt-query" autocomplete="off" spellcheck="false" name="textemployeeid"  id="textemployeeid"  placeholder="Enter"> 
                                  <span class="input-group-btn">
                                  <button type="button" id="search" class="btn btn-xs btn-danger" style="background-color:red;">
                                  <span class="input-group-addon"><i class="glyphicon glyphicon-search "  aria-hidden="true"></i></span>
                                  </button>    
                                  </span>
                               </div>
                            </div>
                         </div>
                      </form>
                   </div>
                </div>
             </div>
          </div>
       </body>
    </html>