Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/478.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript php中的wrap_Javascript_Php_Html_Css_Forms - Fatal编程技术网

Javascript php中的wrap

Javascript php中的wrap,javascript,php,html,css,forms,Javascript,Php,Html,Css,Forms,在内容完整的课堂上,我使用了单词包装:打断单词;文本仍然没有以正确的格式显示?可能的解决方案是什么?是否有一些方法可以获得正确的格式,以便允许长单词能够断开并换行到下一行。但最关键的部分是内容短单词换行:断开单词正在工作 echo "<div class='mainlayout' data-js-module='layout'>"; echo "<div class='grid' style='position: relative;'>"; include "mysql.

在内容完整的课堂上,我使用了单词包装:打断单词;文本仍然没有以正确的格式显示?可能的解决方案是什么?是否有一些方法可以获得正确的格式,以便允许长单词能够断开并换行到下一行。但最关键的部分是内容短单词换行:断开单词正在工作

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>";  
?>  
echo”“;
回声“;
包括“mysql.php”;
$query=“按ID DESC从内容顺序中选择ID、标题、摘要、内容、ImgName、图像”;
$result=mysql\u查询($query,$db);
而($row=mysql\u fetch\u数组($result)){
回声“;
回声“;
$string=$row['Content'];
如果(strlen($string)>200){
$trimstring=substr($string,0200)。“…”;
} 
否则{
$trimstring=substr($string,0)。“…”;
}
echo$trimstring字符串;
回声“;
回声“;
echo$row['Content'];
回声“;
回声“;
}
mysql_close($db);
回声“;
回声“;
?>  
以及内容完整的样式

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

更新:

如果是外部的,它将类似于:

<link rel="stylesheet" type="text/css" href="pathto.css">

父div绕过此div样式,尝试更改父div的样式,如下所示:

更改此行:

 echo "<div class='grid-item item1' style='position: relative; left: 240px; top: 0px; background: ".ran_col().";'>";
echo”“;
据此:

 echo "<div class='grid-item item1' style='position: relative; word-wrap: break-word; left: 240px; top: 0px; background: ".ran_col().";'>";
echo”“;

它将继承您提到的div

这就是您想要实现的吗? 如果是这样,只需将以下内容添加到当前CSS中:

-ms-word-break: break-all;
 word-break: break-word;
-webkit-hyphens: auto;
   -moz-hyphens: auto;
    -ms-hyphens: auto;
        hyphens: auto;
您还需要在div中添加“lang=en”作为参数,否则它在firefox中无法工作。 如果您的文本不是英语,请检查是否支持该语言:

我遇到了与您相同的问题,我正在使用docx文件中的文本,并且在上载时使用了pre标记,因此word wrap无法正常工作。如果是这种情况,请删除前置标记。

如果您的类名为“内容完整”,为什么要将其样式设置为“内容完整数据”?感谢您的编辑。我刚刚将其更改为。内容完整这是一个键入错误@Arturo您尝试过添加“显示:内联块”吗是的,我还是一样problem@Arturoi使用外部样式表@Mohammed Elhag我使用了相同的语法链接到外部样式表@Mohammed Elhag谢谢,但我已经编写了正确的类@Mohammed Elhag我确信上述迪夫,那还不算吗effect@MohammedElhagi希望实现与您在JSFIDLE链接中提供的相同的功能,但它对我不起作用@Arturo@aryan_kanwar检查影响该div的所有CSS属性,如果它在jsfiddle中工作,那么它必须为您工作。你的文章是用哪种语言写的?用英语写的@Arturo@aryan_kanwar您是否已将lang=“en”参数添加到div中?@aryan_kanwar您是否可以使用您的非工作内容尝试创建一个JSFIDLE并将其链接到此处?