2

trying to make my comments box scrollable using overflow:scroll. at first I thought it wasn't working cause I was using max-height over just height but even with a fixed height the scroll bar does not appear and the comments push their 400px boundary.

Here is the code of the comments box.

<?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
}
?>

and here is the css style for it.

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

anyone got any ideas to why it won't do it? is it because im populating the div with php or something?

thanks in advance.

4

2 回答 2

1

以下行没有结束}

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

这可能不是它应该出现的样子,因为在chrome中我检查了css文件并且它在那里但是在div的属性中它没有显示height:400px; overflow:scroll;但是当我添加它时}它起作用了。很可能它看到缺少 a}并且大多数浏览器都试图猜测缺少的信息去哪里,并将其放在文件的末尾/最后一行(您不会在视图源中看到这个,或者什么都没有,但它完成了内部)浏览器的窗口也不是最大/屏幕 600 像素。

于 2013-05-17T03:02:03.727 回答
0

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

于 2013-05-17T02:37:05.160 回答