我对css的态度不是很强,但我有两种形式:
//below is where it displays course name
$outputcourse = "";
$outputcourse .= "<p><strong>Course:</strong> " . $course . " - " . $coursename . "</p>";
//below is where it displays module name
$outputmodule = "";
$outputmodule = sprintf("<p><strong>Module:</strong> %s - %s</p>", $moduleId, $moduleName);
//below is form where it displays assessments drop down menu
$assessmentform = "<form action='".htmlentities($_SERVER['PHP_SELF'])."' method='post'>
<p>{$outputcourse}</p>
<p>{$outputmodule}</p>
<p><strong>Assessments:</strong> {$sessionHTML} </p>
</form>";
echo $assessmentform;
}
//below is form where it displays all of the text inputs and submit button
$editsession = "<form id='updateForm'>
<p><strong>Current Assessment's Date/Start Time:</strong></p>
<table>
<tr>
<th>Assessment:</th>
<td><input type='text' id='currentAssessment' name='Assessmentcurrent' readonly='readonly' value='' /> </td>
</tr>
<tr>
<th>Date:</th>
<td><input type='text' id='currentDate' name='Datecurrent' readonly='readonly' value='' /> </td>
</tr>
<tr>
<th>Start Time:</th>
<td><input type='text' id='currentTime' name='Timecurrent' readonly='readonly' value=''/> </td>
</tr>
</table>
<div id='currentAlert'></div>
<p><strong>New Assessment's Date/Start Time:</strong></p>
<table>
<tr>
<th>Assessment:</th>
<td><input type='text' id='newAssessment' name='Assessmentnew' readonly='readonly' value='' /> </td>
</tr>
<tr>
<th>Date:</th>
<td><input type='text' id='newDate' name='Datenew' readonly='readonly' value='' /> </td>
</tr>
<tr>
<th>Start Time:</th>
<td><input type='text' id='newTime' name='Timenew' readonly='readonly' value=''/><span class='timepicker_button_trigger'><img src='Images/clock.gif' alt='Choose Time' /></span> </td>
</tr>
</table>
<div id='datetimeAlert'></div>
</form>
<p><button id='updateSubmit'>Update Date/Start Time</button></p>
<div id='targetdiv'></div>
";
echo $editsession;
Run Code Online (Sandbox Code Playgroud)
CSS:
form#assessmentForm {
float: left;
border: 1px solid red;
}
form#updateForm {
float:left;
clear: right;
/* with some space to the left of the second form */
margin-right: 100px;
}
p#submitupdatebtn {
clear: both;
}
Run Code Online (Sandbox Code Playgroud)
目前,两种形式都显示在彼此之上.我真正想做的是在右侧$editsession的$assessmentform表格旁边显示的显示表格,两个表格之间有一点空间.
怎么能实现这一目标?我希望这适用于所有主流浏览器.
下面显示了两个合并在一起的屏幕截图,以显示我希望如何显示它:

谢谢
更新:
现在下面是它显示的内容:

您只需要float: left;表单,建议也clear: right;使用第二种形式,以便其他浮动元素不会出现在它的右侧.最后,clear: both;在<p>第二种形式之后,所以前面的元素没有浮动到它的左边或右边.
form {
/* Float both forms to the left */
float: left;
/* borders added for visibility. Just remove them */
border: 1px solid red;
}
form#updateForm {
clear: right;
/* with some space to the left of the second form */
margin-right: 20px;
}
/* Give an id to the <p> which follows the second form and clear: both */
p#submit {
clear: both;
}
Run Code Online (Sandbox Code Playgroud)
在你的标记中,给<p>第二个表单后面的id 赋予一个id,这样它就可以很容易地在CSS中定位
<p id='submit'><button id='updateSubmit'>Update Date/Start Time</button></p>
Run Code Online (Sandbox Code Playgroud)
然后移动它里面前述<form>标签,因为它是那种形式的一部分.