我不确定我的CSS出错了...任何帮助都会受到赞赏..
CSS
#commentbox {
float: left;
margin-top: 10px;
background-color: #FFFFF0;
display: block;
width: 450px;
border: 1px solid #999999;
padding: 10px;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
text-align: left;
}
#commentbox .commenter_name {
font-family: "Courier New", Courier, monospace;
font-size: 14px;
color: #660000;
float: left;
padding-left: 5px;
display: block;
}
#commentbox .comment_content {
display: block;
float: left;
clear: both;
white-space: pre-wrap;
}
这是我的Form Textarea
<textarea name="vt_comment" cols="50" rows="5" wrap="hard" class="nontextarea" ></textarea>
这是显示评论的代码
<?php if ($totalRows_cmnts_disp>0) { // Show only if there are Comments
do { ?>
<div id="commentbox">
<!--Show Commenter Name -->
<div class="commenter_name">
<?php if ($row_cmnts_disp['member_nick']>"") {
echo $row_cmnts_disp['member_nick'] ;
} else {
echo $row_cmnts_disp['member_fname'] . ' ' . $row_list_solo['member_sname'] ;
} ?> commented
</div>
<!--Show Comment -->
<div class="comment_content">
<?php echo $row_cmnts_disp['vt_comment']; ?>
</div>
</div>
<?php } while ($row_cmnts_disp = mysql_fetch_assoc($cmnts_disp));
} // Show only if there are Comments loop ends
?>
这是它存储在数据库中的方式
1st Line of the Comment
2nd Line of the Comment with just a Line break
Double Line Break
这就是它在网站上的显示方式(第一行前面有空格)
Swami Donanandha commented
hello
hello
hello
hello
无论我尝试做什么更改,我都无法删除评论第一行之前的空格,除非我删除了CSS中的空格:预包装设置...如果我这样做线条消失,只显示一句话......
Swami Donanandha commented
1st Line of the Comment 2nd Line of the Comment with just a Line break Double Line Break
答案 0 :(得分:0)
我把它整理出来......通过在数据库插入之前添加nl2br子句
$vt_comment = nl2br($_POST['vt_comment']);
并删除空格:从CSS中预先包装
虽然我仍然不知道为什么额外的空格会在之前添加:-)