2017-05-13 6 views
2

データリストを中央(縦と横)に整列させてスタイルを設定しようとしていますが、ボタンが付いた垂直と水平のセンタリングデータリストボックス

データリストボックスの幅を広げてスタイリングを行う方法はありますか? display: flexalign-items: centerを使用し、縦方向にデータリストを揃えるために...

$('#btn').click(function() { // The `$` reference here is a jQuery syntax. So we are loading jquery right before this script tag 
 
     var textval = $('#textcat').val(); 
 
     window.location = "1stlink.php?variable=" + encodeURIComponent(textval); 
 
     });
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
    
 
    <div class="container"> 
 
     <div class="row"> 
 
     <div class="col-md-6 col-md-offset-3"> 
 
    <div class="text-center"> 
 
    <input list="category" name="category" id="textcat" placeholder="Enter your area.."> 
 
    <datalist id="category"> 
 
     <option id="www.google.com" value="fruits" /> 
 
     <option id="www.fb.com" value="animals" /> 
 
     <option id="www.ymail.com" value="vechiles" /> 
 
     <option id="www.msn.com" value="ornaments" /> 
 
    </datalist> 
 
    <input id="btn" type="button" value="submit"> 
 
    
 
    </div> 
 
    </div> 
 
    </div>

答えて

1

を助けてください。コンテナの高さを設定して内容を垂直に合わせる必要があることに注意してください。

ちょうど幅について注意しました。これを調整するには、データリストのidを使ってwidthプロパティを調整するだけです。

Updated Fiddle

.container { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    flex-direction: column; 
    height: 100vh; 
} 
+0

ために、このページを参照してくださいには、私は幅が、私は取得couldnot垂直センタリングを高めることができる可能性あなたの答えを通じて – prog

2

"入力"要素では、好みに応じて要素の幅を簡単に調整できます。

詳しく https://www.w3schools.com/css/css_form.asp

$('#btn').click(function() { // The `$` reference here is a jQuery syntax. So we are loading jquery right before this script tag 
 
    var textval = $('#textcat').val(); 
 
    window.location = "1stlink.php?variable=" + encodeURIComponent(textval); 
 
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> 
 
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 
 
<div class="container"> 
 
    <div class="row" style="width: 100%; padding-top: 25%"> 
 
    <div class="col-md-6 col-md-offset-3"> 
 
     <div class="text-center"> 
 
     <input style="width: 100%" list="category" name="category" id="textcat" placeholder="Enter your area.."> 
 
     <datalist id="category"> 
 
      <option id="www.google.com" value="fruits" /> 
 
      <option id="www.fb.com" value="animals" /> 
 
      <option id="www.ymail.com" value="vechiles" /> 
 
      <option id="www.msn.com" value="ornaments" /> 
 
     </datalist> 
 
     <input id="btn" type="button" value="submit"> 
 
     </div> 
 
    </div> 
 
    </div>

+0

このモバイル応答を行うことでした。私が懐かしいものがありますか – prog

+0

今すぐコードをチェックしてください...私は行クラスのパディング設定を変更しました –

関連する問題