【问题标题】:Can't set TD height in PHP generated table无法在 PHP 生成的表格中设置 TD 高度
【发布时间】:2013-07-21 10:03:37
【问题描述】:

我有一个表单,访问者可以在其中填写信息,在后端,我创建了一个页面,该页面将显示此信息供客户查看。该表正在通过 PHP 填充。在其中一个字段中,访问者可以输入最多 3,000 个字符的叙述,​​因为这可能会很长,我想设置一个高度并添加一个滚动条。但是,我无法设置高度。

PHP

<?php get_header(); the_post(); ?>

<h1>Prayer Requests</h1>

<?php

$mysqli = new mysqli('localhost', 'root', '', 'aln');
$query = $mysqli->prepare("SELECT `title`, `firstName`, `lastName`, `email`, `address`,     `city`, `state`, `zip`, `country`, `prayer`, `timestamp` FROM `prayerrequests` WHERE 1");
$query->execute();


$query->bind_result($title, $first, $last, $email, $address, $city, $state, $zip,     $country, $prayer, $timestamp)
?>
<table>
<tr><td class="header">Title</td><td class="header">First Name</td><td class="header">Last Name</td><td class="header">E-mail Address</td><td class="header">Address</td><td class="header">City</td><td class="header">State</td><td class="header">Zip Code</td><td class="header">Country</td><td class="header">Prayer</td><td class="header">Date Submitted</td></tr>
<?php
while($query->fetch()) {
echo "<tr><td>$title</td><td>$first</td><td>$last</td><td>$email</td><td>$address</td><td>$city</td><td>$state</td><td>$zip</td><td>$country</td><td>$prayer</td><td>$timestamp</td></tr>";
}
?>
</table>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

CSS

table {
margin: 0 auto;
border: 1px solid #000;
background: #32458b;
background: rgb(54, 79, 139);
background: rgba(54, 79, 139, 0.5);
border-spacing: 0;
border-collapse: collapse;
height: auto;
width: 1000px;
margin-bottom: 20px;
}

tr, td {
border: 1px solid #000;
color: #f1f1f2;
height: 200px;
overflow: scroll;
}

.header{
background: #32458b;
background: rgb(54, 79, 139);
background: rgba(54, 79, 139, 0.8);
}

【问题讨论】:

    标签: php html forms html-table


    【解决方案1】:

    一般来说,您会将表格包装在 DIV 中,然后调整 DIV 的大小并为其添加滚动条,而不是表格本身。

    【讨论】:

    • 谢谢,我最终只是在叙述中添加了一个 div 并设置了该 div 的高度并添加了一个滚动条。
    猜你喜欢
    • 2018-11-25
    • 2012-12-13
    • 1970-01-01
    • 2011-09-12
    • 1970-01-01
    • 2013-09-01
    • 1970-01-01
    • 2010-11-12
    • 1970-01-01
    相关资源
    最近更新 更多