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">&nbsp;<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 "&nbsp;";
echo "|&nbsp;";
echo "<a href = 'logout.php'>Log out</a>&nbsp;";
echo "|&nbsp;";
}
echo "<a href = 'home.php'>Home</a>";
if(!isset($_SESSION['user'])||$_SESSION['user']=="")
{
echo "&nbsp;|&nbsp;";
echo "<a href = 'login.php'>Log in</a>&nbsp;|&nbsp;";
echo "<a href = 'signup.php'>Sign up</a>&nbsp;";
}

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">&nbsp;<input type = "radio" value = "Search topics" name = "topics" id = "topics">
<input type = "Submit" value = "Go">
</form>
</div>
</body>
</html> 
4

1 に答える 1

0

そのフォームに近い要素に float プロパティを適用していますか? その場合は、追加してみてください <div style="float: none; clear: both;"></div>

また

フォームの親 div を削除し、div のスタイルをフォーム自体に適用するだけです。

于 2013-05-03T13:25:46.930 に答える