簡體   English   中英

對齊 div 是並排的?

[英]Aligning divs are side-by-side?

我正在為一個旅游網站創建這個界面,我正在並排對齊兩個輸入,但它們沒有正確對齊。 我最關心的是出發和返回輸入。 返回輸入和 label 未與出發輸入和 label 對齊。

有人可以檢查我的代碼並提出解決方案。 這可能是我的願景,但如果你能幫助我,我將不勝感激。

 #container { width: 400px; height: 400px; background-color: black; float: left; } #menu { background-color: black; clear: both; } #flights { font-family: helvetica, sans-serif; font-size: 20px; font-weight: bold; width: 100px; height: 50px; color: white; background-color: black; float: left; line-height: 50px; text-align: center; } #flights:hover { cursor: pointer; background-color: gold; color: black; } #hotels { font-family: helvetica, sans-serif; font-size: 20px; font-weight: bold; width: 100px; height: 50px; color: white; background-color: black; float: left; line-height: 50px; text-align: center; } #hotels:hover { cursor: pointer; background-color: gold; color: black; } #cars { font-family: helvetica, sans-serif; font-size: 20px; font-weight: bold; width: 100px; height: 50px; color: white; background-color: black; float: left; line-height: 50px; text-align: center; } #cars:hover { cursor: pointer; background-color: gold; color: black; } #bundle { font-family: helvetica, sans-serif; font-size: 20px; font-weight: bold; width: 100px; height: 50px; color: white; background-color: black; float: left; line-height: 50px; text-align: center; } #bundle:hover { cursor: pointer; background-color: gold; color: black; } #flights-data { font-family: helvetica, sans-serif; font-size: 14px; font-weight: bold; width: 400px; height: 400px; float: left; margin-top: 0; background-color: gold; padding: 10px; } label { width: 180px; height: ''; float: left; margin: 0; padding: 0; } input#flight-departure { display: inline-block; width: 48%; height: 50px; padding: 10px; float: left; margin-right: 10px; margin-top: 0; display: block; margin-bottom: 5px; } input#flight-return { display: inline; width: 48%; height: 50px; padding: 10px; float: left; margin-right: 0px; margin-top: 0; margin-bottom: 5px; } input#fly-from, input#fly-to, input#passengers { display: block; width: 380px; height: 50px; margin-bottom: 5px; padding: 10px; } #depart-block { column-count: 2; column-gap: 10px; width: 385px; height: 100px; padding: 0; margin: 0; float: left; } #find-a-flight { width: 380px; height: 50px; line-height: 50px; background-color: black; color: white; border-radius: 30px; text-align: center; margin-top: 10px; } #find-a-flight:hover { cursor: pointer; background-color: white; border: 2px solid black; color: black; } label#return { margin: 0; } div.active#flights { background-color: gold; color: black; }
 <div id="container"> <div id="menu"> <div class="active" id="flights">Flights</div> <div id="hotels">Hotels</div> <div id="cars">Cars</div> <div id="bundle">Bundle</div> </div> <div id="flights-data"> <label for="fly-from">Flying from</label><br> <input type="text" id="fly-from" value="Departure city or Airport"> <label for="fly-to">Flying to</label><br> <input type="text" id="fly-to" value="Departure city or Airport"><br> <div id="departing-block"> <label for="Departure">Departing Flight</label><br> <input type="text" id="flight-departure" value="Pick-a-date"> <label id="return" for="Return">Returning</label><br> <input type="text" id="flight-return" value="Pick-a-date"> </div> <label for="passengers">Passengers</label><br> <input type="text" id="passengers" value="1 Adult 0 Children"> <div id="find-a-flight">Find a Flight</div> </div>

<div id="flights-data">中進行以下更改:

    <label for="fly-from">Flying from</label><br>
    <input type="text" id="fly-from" value="Departure city or Airport">
    <label for="fly-to">Flying to</label><br>
    <input type="text" id="fly-to" value="Departure city or Airport"><br>
    <div id="departing-block">
      <div style="display: inline-block;">
      <label for="Departure">Departing Flight</label><br>
      <input type="text" id="flight-departure" value="Pick-a-date"> 
      </div>

      <div style="display: inline-block;">
      <label id="return" for="Return">Returning</label><br>
      <input type="text" id="flight-return" value="Pick-a-date">    
      </div>
      
     
    </div>
    <label for="passengers">Passengers</label><br>
    <input type="text" id="passengers" value="1 Adult 0 Children">
    <div id="find-a-flight">Find a Flight</div>
  </div>

這將正確地並排對齊兩個輸入。 我已經檢查過了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM