我在我的博客proj中有一个问题,我有一个textarea,用户可以键入并将其传递给我的mysql表,问题是我的<li>
上的文本溢出我尝试了wordwrap()但是还有其他文字一直溢出我不知道如何“格式化”它以便自动将它格式化为适合我的div或我这样做的方式是错误的oO ?,明显的PHP新手:P ..
感谢...
<?php
session_start();
function __autoload($className)
{
require $className . '.php';
}
$emptyMsg ='';
$conn=new connection();
$conn->conn('localhost','****','');
if(!isset($_SESSION['username']))
{
die('Log In 1st!<a href="loginpage.php">Log In</a>');
}
$query = "SELECT blog_content FROM tbl_blog";
$queryResult=mysql_query($query) or die();
?>
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
p
{
}
#nav
{
}
ul li
{
list-style:none;
}
#blog_wrap
{
clear:both;
width:800px;
height:600px;
margin:0 auto;
background-color:blue;
}
.content
{
width:700px;
clear:both;
float:left;
height:auto;
background-color:gray;
color:lightgreen;
text-align:left;
margin:10px 0 0 50px;
}
.content ul li
{
color:red;
background-color:green;
overflow:visible;
}
.content2
{
width:700px;
clear:both;
float:left;
height:auto;
background-color:yellow;
color:lightgreen;
margin:10px 0 0 50px;
}
</style>
</head>
<body>
<div id="nav" >
<ul >
<li>Welcome!!!<?php echo $_SESSION['username']; ?></li>
<li><a href="">Edit Account</a></li>
<li><a href="createBlog.php">Create Blog</a></li>
<li>Home</li>
<li>Sign Out</li>
</ul>
</div>
<div id="blog_wrap">
<?php
$count=0;
while($rows=mysql_fetch_array($queryResult))
{
if($count % 2 ==0)
{
echo '<div class="content">';
echo '<ul>';
echo '<li>' . $rows['blog_content'] . '</li>';
echo '</ul>';
echo '</div>';
}
else
{
echo '<div class="content2">';
echo '<ul>';
echo '<li>' . $rows['blog_content'] . '</li>';
echo '</ul>';
echo '</div>';
}
$count++;
}
?>
</div>
</body>
</html>
答案 0 :(得分:1)
您需要更改CSS类.content。它应该是:
.content {
width:700px;
clear:both;
float:left;
height:auto;
background-color:gray;
color:lightgreen;
text-align:left;
margin:10px 0 0 50px;
overflow: hidden
}
将“overflow:hidden”添加到固定宽度的容器可防止内容流出。