在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下方的表单。为什么会这样做,我该如何解决?
编辑:我省略了一些PHP echos
部分HTML代码。这是我的完整代码:
<!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>
答案 0 :(得分:0)
您是否有任何浮动属性应用于更接近该表单的元素?如果是这种情况,请尝试添加<div style="float: none; clear: both;"></div>
或
只需删除表单的父div并应用div的样式来形成自己。