表内div溢出滚动块

时间:2013-04-16 05:05:00

标签: php css html overflow

我从数据库中获取循环记录,我试图将这些记录放入带有溢出的div块中,以允许用户滚动每个列表的长列表,不知何故当我在代码下方显示时,div块看起来很乱而没有滚动,如何将表格放在div块内溢出?

<div style="overflow:auto;height:100px;width:358px;">
    <table width="100%" border="1" cellpadding="3" cellspacing="0">
        <tr>
            <td><input id="" class="" name="ids[]" type="checkbox" value="<?php echo $user_email; ?>" /></td>
            <td><?php echo $user_name; ?></td>
            <td><?php echo $user_email; ?></td>
        </tr>

        <?php
        $query2 = "SELECT * FROM sub_user where parent_user_id=".$row['user_id'];
        $result2 = mysql_query($query2);

        while($row2 = mysql_fetch_assoc($result2)){
            $user_name = stripslashes($row2['user_name']);
            $su_position = stripslashes($row2['su_position']);
            $su_telephone = stripslashes($row2['su_telephone']);
            $user_email = stripslashes($row2['user_email']);
        ?>

        <tr>
            <td><input id="" class="" name="ids[]" type="checkbox" value="<?php echo $user_email; ?>" /></td>
            <td><?php echo $user_name; ?></td>
            <td><?php echo $user_email; ?></td>
        </tr>
        <?php
        }
        ?>
    </table>
</div>

请指教。感谢。

1 个答案:

答案 0 :(得分:0)

你试过这个吗?

<div style="overflow-y: scroll;height:100px;width:358px">
<table width="100%" border="1" cellpadding="3" cellspacing="0">
    <tr>
        <td><input id="" class="" name="ids[]" type="checkbox" value="<?php echo $user_email; ?>" /></td>
        <td><?php echo $user_name; ?></td>
        <td><?php echo $user_email; ?></td>

    </tr>

    <?php
    $query2 = "SELECT * FROM sub_user where parent_user_id=".$row['user_id'];
    $result2 = mysql_query($query2);

    while($row2 = mysql_fetch_assoc($result2)){
        $user_name = stripslashes($row2['user_name']);
        $su_position = stripslashes($row2['su_position']);
        $su_telephone = stripslashes($row2['su_telephone']);
        $user_email = stripslashes($row2['user_email']);
    ?>

    <tr>
        <td><input id="" class="" name="ids[]" type="checkbox" value="<?php echo $user_email; ?>" /></td>
        <td><?php echo $user_name; ?></td>
        <td><?php echo $user_email; ?></td>
    </tr>
    <?php
    }
    ?>
</table>