[英]Not able to get input field at the center of the screen
我在JSP頁面中有一個輸入字段,希望它位於屏幕的中心,但是即使嘗試了各種方法,它也沒有發生。 包含輸入的div看起來像這樣
<div class="text-center" id="keywordSelect"> <div class="text-center"> <p style='text-align:center'> <input type="text" class="form-control" id="keyword" name="name" placeholder="Enter Keyword" style='width:30em;display:block'> </p> </div> <div class="text-center"> <button type="button" class="btn btn-success" id="keyword_button">View</button> </div> </div>
嘗試使用此代碼。它將在屏幕中央顯示您的字段。
<div class="text-center" id="keywordSelect" align="center">
<div class="text-center">
<p>
<input type="text" class="form-control" id="keyword" name="name"
placeholder="Enter Keyword" style='width: 30em; display: block'>
</p>
</div>
<div class="text-center">
<button type="button" class="btn btn-success" id="keyword_button">View</button>
</div>
</div>
增加margin:0 auto
<input type="text" class="form-control" id="keyword" name="name"
placeholder="Enter Keyword" style='width: 30em; display: block; margin:0 auto;'>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.