溢出:滚动在PHP评论系统中不起作用


overflow:scroll isn't working for php comment system

尝试使用overflow:scroll使我的评论框可滚动。一开始我以为它不工作,因为我使用的是max-height而不是height,但即使有固定的高度,滚动条也不会出现,并且评论推到了400px的边界。

这是注释框的代码。

<?php
$act = $_POST['act'];
if($act == "post") {
$name = $_POST['name'];
$message  = $_POST ['message'];
@$fp = fopen("comments/comments.php", 'a');
if (!$fp) {
    //The file could not be opened
    echo "There was an error! Please try again later!";
    exit;
} else {
    //The file was successfully opened, lets write the comment to it.
    $outputstring = 
    "<article class='comment'>
    <br>
    <p><span class='label'>Name:</span> " .$name. "</p>
    <br> 
    <p><span class='label'>Comment:</span>" .$message. "</p>
    <br>
    <hr/ >
    </article>";
    //Write to the file
    fwrite($fp, $outputstring, strlen($outputstring));
    //We are finished writing, close the file for security / memory management purposes
    fclose($fp);
    //Post the success message
    echo "Your post was successfully entered. Click <a href='index.php'>here</a> to continue.";
}
} else {
//We are not trying to post a comment, show the form.
?>
//THIS HERE IS THE COMMENTS SECTION DIV
<div class="commentSection">
<h3>comments:</h3>
<hr/>
<?php include("comments/comments.php"); ?>
</div>
//THIS HERE IS THE COMMENTS SECTION DIV

<br><br>
<h3>Post a comment:</h3>
<form action="index.php" method="post">
<label>Name:<label>
<input type="text" name="name" value=""></input>
<br/>
<label>Comment:</label>
<textarea name="message"></textarea>
<input type="hidden" name="act" value="post"></input>
<br/>
<input type="submit" name="submit" value="Submit"></input>
</form>
<?php
}
?>

,这是它的CSS样式

.commentSection{
height:400px;
overflow:scroll;
}

有人知道为什么它不会这样做吗?是因为我在用PHP填充div吗?

下一行没有结束的}

@media screen and (max-width: 600px) {

这可能是它没有出现它应该如何,因为在chrome我检查了css文件,它在那里,但在div的属性它没有显示height:400px; overflow:scroll;,但当我添加了}它工作。最有可能的是,它看到有缺失的}和大多数浏览器尝试猜测丢失的信息去哪里,它把它放在文件/最后一行的末尾(你不会看到这在视图源或什么不是,但它在内部完成)也浏览器的窗口不是600px max/screen。

如果comments.php文件中的HTML是无效的,它将破坏包含div的代码,从而破坏代码并阻止预期的样式。