我对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;
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;
}
目前,两种形式都显示在彼此之上。我真正想做的是显示$editsession
表单,显示在右侧的$assessmentform
表单旁边,两个表单之间有一点空格。
如何实现这一目标?我希望这适用于所有主流浏览器。
下面显示了两个合并在一起的屏幕截图,以显示我希望如何显示它:
由于
更新:
下面是它显示的内容:
答案 0 :(得分:7)
您只需要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;
}
在你的标记中,给第二个表单后面的<p>
一个id,这样可以很容易地在CSS中定位
<p id='submit'><button id='updateSubmit'>Update Date/Start Time</button></p>
然后在里面移动前面的<form>
标记,因为它是该表单的一部分。
答案 1 :(得分:0)
使用浮动
您只需将其添加到您的第一个表单标记
即可然后第二个跳到你的第一个表格的右边