Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.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
Css 如何在段落中显示宽度为100%的一行文本,这是表格单元格的一部分?_Css_Html_Xhtml_Html Table - Fatal编程技术网

Css 如何在段落中显示宽度为100%的一行文本,这是表格单元格的一部分?

Css 如何在段落中显示宽度为100%的一行文本,这是表格单元格的一部分?,css,html,xhtml,html-table,Css,Html,Xhtml,Html Table,我举一个例子: <table class="border" style="width:100%"> <tr> <td style="width:30%" class="border p10"> Test </td> <td style="width:70%" class="border p10"> <p class="longText"> Looong

我举一个例子:

<table class="border" style="width:100%">
<tr>
    <td style="width:30%" class="border p10">
        Test
    </td>
    <td style="width:70%" class="border p10">
        <p class="longText">
        Looong text Looong text Looong text Looong text Looong text Looong text Looong text Looong text
        </p>
    </td>
</tr>
你可以在这里试试

问题是长文本会破坏单元格的宽度30%和70%。如果我将.longText的宽度设置为PX,例如200px,那么表格就可以了。但是我需要

占细胞的100%。如何解决此问题?

您应该应用表格布局:已修复:

请看这里的小提琴:这是你想要达到的结果吗?现在表格行的比例为30/70。

您应该应用表格布局:固定:

请看这里的小提琴:这是你想要达到的结果吗?现在表格行的比例为30/70。

删除空白:nowrap;添加有助于逐字断行的换行符

.longText {
    overflow:hidden; 
    text-overflow:ellipsis;width:100%;
    word-wrap:break-word;
}
删除空白:nowrap;添加有助于逐字断行的换行符

.longText {
    overflow:hidden; 
    text-overflow:ellipsis;width:100%;
    word-wrap:break-word;
}

100%将占据整个浏览器宽度,具体取决于您的显示器。如上所述,使用表布局:固定 或
使用px而不是%将您的表格固定在任何显示器分辨率上

100%将占据整个浏览器宽度,具体取决于您的显示器。如上所述,使用表布局:固定 或
使用px而不是%将您的表格固定在任何监视器分辨率上

是!你救了我的时间!从未使用过此css属性。谢谢-对你救了我的时间!从未使用过此css属性。谢谢-
.longText {
    overflow:hidden; 
    text-overflow:ellipsis;width:100%;
    word-wrap:break-word;
}