窗体显示
问题描述:
在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 style="float: none; clear: both;"></div>
或
只是删除形式的父DIV和应用div的风格,形成自己。
+0
有一个标题。我省略了一些代码,因为它从PHP中回应了很多。我现在编辑我的问题。 – imulsion 2013-05-04 07:16:23
是不是形式的块级元素?你的表单是否真的需要在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