我有以下内容,我想知道是否可以增加宽度来使台式机版本占用我的td单元格大部分宽度?
我尝试添加一个宽度,但是无法使其扩展,但是我将其作为空白:换行。如果我摆脱了麻烦,那么它确实可以工作,但是我无法分解为下一行:
这是我的代码:
<?php
include_once __DIR__. '/header2.php';
if(!isset($_SESSION['u_uid']))
{
header("Location: index.php?practice_diary_view=notlogin");
exit();
}
else
{
include_once __DIR__. '/includes/dbh.php';
$sql = "SELECT * FROM student_details WHERE id = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql))
{
echo "SQL error";
}
else
{
mysqli_stmt_bind_param($stmt, "i", $_SESSION['u_id']);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$row = mysqli_fetch_assoc($result);
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$sql2 = "SELECT * FROM practice_diary WHERE first_name = ? AND last_name = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql2))
{
echo "SQL error";
}
else
{
mysqli_stmt_bind_param($stmt, "ss", $first_name, $last_name);
mysqli_stmt_execute($stmt);
$result2 = mysqli_stmt_get_result($stmt);
$resultCheck2 = mysqli_num_rows($result2);
if($resultCheck2 < 1)
{
echo '<div class="nopracticediaryview">There are no practice diary records associated with this user</div>';
exit();
}
else
{
echo '<table class="practice_diary_view">
<tr>
<th colspan="3" class="update_title">Welcome to the Practice Diary Viewing Section</th>
</tr>
<tr>';
while ($row2 = mysqli_fetch_assoc($result2))
{
echo '<tr>
<th>Username:</th><td>',htmlspecialchars($row2['user_uid']),'</td>
</tr>
<tr>
<th>First Name:</th><td>',htmlspecialchars($row2['first_name']),'</td>
</tr>
<tr>
<th>Last Name:</th><td>',htmlspecialchars($row2['last_name']),'</td>
</tr>
<tr>
<th>Lesson Title:</th><td>',htmlspecialchars($row2['lesson_title']),'</td>
</tr>
<tr>
<th>Describe Lesson:</th><td class="describe_lesson">',htmlspecialchars($row2['describe_lesson']),'</td>
</tr>
<tr>
<th>Hours of Practice:</th><td>',htmlspecialchars($row2['hours_practice']),'</td>
</tr>
<tr>
<th>Date of Practice:</th><td>',htmlspecialchars($row2['date_practice']),'</td>
</tr>';
}
echo '</table>';
}
}
}
}
?>
这是我的CSS代码:
.practice_diary_view .describe_lesson
{
white-space: nowrap;
font-size: 1em;
text-align: justify;
text-justify: inter-word;
line-height: 1.5em;
width: 5em;
height: 2em;
}
答案 0 :(得分:0)
尝试在TR而不是TD上添加带有百分比的最小宽度
答案 1 :(得分:0)
说实话,如果您发布的html是表格中的html,则似乎有点破损。 您设置了一个包含3列的表格:在第一行上,您将第一个单元格跨到另外2个单元格上,但是在while循环中,您只考虑了2个单元格而不是3个单元格。您可能希望将colspan减小为2个,否则,如果需要将其设置为3,则可能需要在每行的第二列上添加colspan 2。这应该使宽度跨整个表格宽度。 我也为 tr 担心,因为您在此之前就打开了(并且以后没有关闭或使用它):请尝试将其删除。 因此,您无需阻止空格换行,而需要将其删除。