0
在IE中,這個代碼顯示了頂部DIV,它應該裏面的形式:窗體顯示
<div style = 'height:100px;background-color:#FF6600'>
<form name = "search" action = "search_result.php" method = "get" style = "text-align:right;">
<input type = "text" name = "query" id = "query" maxlength = "100">
<br />
<input type = "radio" value = "Search users" name = "user" id = "user"> <input type = "radio" value = "Search topics" name = "topics" id = "topics">
<input type = "Submit" value = "Go">
</form>
</div>
但在Chrome中,它顯示在div下面的表格。爲什麼要這樣做,我該如何解決?
編輯:我省略了一些echos
的HTML一些PHP代碼。以下是我的完整代碼:
<!DOCTYPE html>
<html>
<body>
<?php
session_start();
$connect = mysql_connect('localhost','phpuser','mypss');
$db = mysql_select_db('phpuser');
echo "<div style = 'float:none;clear:both;height:100px;background-color:#FF6600'>";
if(isset($_SESSION['user'])&&$_SESSION['user']!="")
{
echo "<a href = 'userinfo.php'>".$_SESSION['user']."</a>";
echo " ";
echo "| ";
echo "<a href = 'logout.php'>Log out</a> ";
echo "| ";
}
echo "<a href = 'home.php'>Home</a>";
if(!isset($_SESSION['user'])||$_SESSION['user']=="")
{
echo " | ";
echo "<a href = 'login.php'>Log in</a> | ";
echo "<a href = 'signup.php'>Sign up</a> ";
}
function trimtext($text)
{
$newtext = substr($text,0,15);
$newtext .= "...";
return $newtext;
}
?>
<h1 style = "color:black">My blog</h1>
<form name = "search" action = "search_result.php" method = "get" style = "text-align:right;">
<input type = "text" name = "query" id = "query" maxlength = "100">
<br />
<input type = "radio" value = "Search users" name = "user" id = "user"> <input type = "radio" value = "Search topics" name = "topics" id = "topics">
<input type = "Submit" value = "Go">
</form>
</div>
</body>
</html>
是不是形式的塊級元素?你的表單是否真的需要在div中? – 2013-05-03 12:46:42
似乎顯示對我很好,http://jsfiddle.net/a3njc/ – Ryan 2013-05-03 12:49:20
不是真的相關,但它是一個很好的做法,增加號碼到您的形式,如果你需要輸入之間更多的空間使用的CSS屬性,而不是
– sylwia 2013-05-03 13:18:19