2014-02-21 204 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