尝试使用overflow:scroll来使我的注释框可滚动。起初我认为它不起作用,因为我在高度上使用了最大高度,但即使是固定高度,滚动条也不会出现,并且注释会推动它们的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?
提前感谢。
答案 0 :(得分:1)
以下行没有结束}
@media screen and (max-width: 600px) {
可能它没有出现它应该如何,因为在chrome我检查了css文件并且它在那里但是在div的属性中它没有显示height:400px; overflow:scroll;
但是当我添加了{{ 1}}它有效。很可能它会发现缺少}
并且大多数浏览器会尝试猜测丢失信息的位置,并将其放在文件/最后一行的末尾(您不会在视图源或什么不是内部完成)浏览器的窗口也不是600px max / screen。
答案 1 :(得分:0)
如果comments.php文件中的HTML无效,它将破坏您的包含DIV,从而破坏代码并阻止预期的样式。