javascript - php 中的自动换行

标签 javascript php html css forms

在 content-full 类中,我使用了 word-wrap: break-word;文本仍然没有以正确的格式出现?可能的解决方案是什么?有什么方法可以获得正确的格式,以便允许长单词能够中断并换行到下一行。但奇怪的部分是对于 content-short word-wrap:break-word 是有效的!

echo "<div class='mainlayout' data-js-module='layout'>";
echo "<div class='grid' style='position: relative;'>";
include "mysql.php";
$query= "SELECT ID,Title,Summary,Content,ImgName,Image FROM content ORDER BY ID DESC";
$result=mysql_query($query,$db);
while($row=mysql_fetch_array($result)) {  
    echo "<div class='grid-item item1' style='position: relative; left: 240px; top: 0px; background: ".ran_col().";'>";           
    echo "<div class='content-short' style='position:relative;'>";
    $string = $row['Content'];
    if (strlen($string) > 200) {
        $trimstring = substr($string, 0,200). '...';
        } 
        else {
            $trimstring = substr($string,0). '...';
            }
    echo $trimstring;
    echo "</div>";
    echo "<div class='content-full'>";
    echo $row['Content'];
    echo "</div>";
    echo "</div>";
    }
mysql_close($db); 
echo "</div>";
echo "</div>";  
?>  

以及内容完整的样式

<style type="text/css>
    .content-full{
        border: 1px;
        border-radius: 5px;
        word-wrap: break-word;
        width: 100%;
        height: 100%;
        padding: 5px 5px 5px 10px;
        overflow-y: auto;
        float: left;
        background: white;}
    .content-short {
        float: left;
        position: relative;
        border: 1px;
        border-radius: 5px;
        margin: 10px 0 0 10px;
        padding: 10px 0 10px 10px;
        word-wrap: break-word;
        height: auto;
        width: 200px;
        background: White;}
</style>

最佳答案

我遇到了同样的问题,我正在使用来自 docx 文件的文本,并且在上传时我使用了预标记,因此自动换行无法正常工作。如果是这种情况,请删除前置标签。

关于javascript - php 中的自动换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32411894/

相关文章:

java - 在基于 Java 的网站上动态更新图表

javascript - 如何使用xpath从用 Angular 编写的网页中提取文本?

php - 在 Woocommerce 的购物车页面上更改购物车总计标题文本

javascript - 在范围 slider javascript 内切换大小写

html - 没有宽度的元素的 CSS 边距

javascript - node.js 中的 http 请求

javascript - 用于捕获单词的正则表达式,无论大小写

php - Twitter api 1.1 的 Oauth header 问题

php - 显示特定的登录用户名

jquery - 使用 jQuery 无法找到动态添加的 HTML 元素