2014-02-21 156 views
0

我想將這兩個表單向右對齊,因爲我在左側有一張地圖,而我不希望這些表單出現在頁面的底部。我不是很擅長css。有人能告訴我怎樣才能把這兩種形式對準嗎?提前致謝。將表單向右對齊

<h2> Save Animal's Location </h2> 
<form action="insert.php" method="post"> 
Animal Type: <input type="text" name="firstname"> 
latitude: <input type ="text" name="lat" > 
longitude <input type ="text" name="lon"> 
Date: <input type="date" name="dateseen"> 
Time: <input type="time" name="timeseen"> 


<br> 
<input type="submit"> 
</form> 

<h2> Search </h2> 
<form action = "search.php" method = "post" > 
    Search for: <input type = "text" name ="find" /> in 
    <select NAME = "field"> 
    <Option VALUE = "Animal Type"> Animal Type</option> 
    <Option VALUE = "latitude"> Latitude</option> 
    <Option VALUE = "longitude"> longitude</option> 
    <Option VALUE = "dateseen"> Date Required</option> 
    <Option VALUE = "timeseen"> Time</option> 
    </Select> 
    <input type= "hidden" name = "searching" value ="yes"/> 
    <input type= "submit" name = "search" value ="Search"/> 
</form> 

回答

0

這裏有一個解決方案:http://jsfiddle.net/panchroma/e92A5/1/

在CSS,寬度值打得到你需要的結果。您可以使用%值,如下所示,或者您可以使用像素值,例如480px

祝你好運!

編輯

使用的地圖信息,請參閱更新的解決方案:

http://jsfiddle.net/panchroma/e92A5/

HTML

<div class="left"> 
map here 
</div> 

<div class= "right"> 

    <h2> Save Animal's Location </h2> 
<form action="insert.php" method="post"> 
Animal Type: <input type="text" name="firstname"> 
latitude: <input type ="text" name="lat" > 
longitude <input type ="text" name="lon"> 
Date: <input type="date" name="dateseen"> 
Time: <input type="time" name="timeseen"> 


<br> 
<input type="submit"> 
</form> 



<h2> Search </h2> 
<form action = "search.php" method = "post" > 
Search for: <input type = "text" name ="find" /> in 
<select NAME = "field"> 
<Option VALUE = "Animal Type"> Animal Type</option> 
<Option VALUE = "latitude"> Latitude</option> 
<Option VALUE = "longitude"> longitude</option> 
<Option VALUE = "dateseen"> Date Required</option> 
<Option VALUE = "timeseen"> Time</option> 
</Select> 
<input type= "hidden" name = "searching" value ="yes"/> 
<input type= "submit" name = "search" value ="Search"/> 
</form> 
</div> 

CSS

.left{ 
float:left; 
width:50%; 
background-color:pink; 
} 
.right{ 
float:right; 
width:50%; 
background-color:#ddd; 
} 
+0

感謝這確實工作,但我的地圖創建的方式,只有當我點擊一個按鈕地圖出現。當地圖出現時,兩種形式會進入右側的底部?任何方式我可以防止這種情況? – user3293736

+0

@ user3293736你可以發佈一個網址來演示嗎? –

+0

http://jsfiddle.net/e92A5/7/ – user3293736