html - 使省略号在 LI 中工作

标签 html css html-lists ellipsis

我已经在这里绞尽脑汁好几个小时了,我似乎找不到问题的答案。

如何让 LI 尊重其父项的大小并正确使用省略号? 情况如下:

<?PHP .... code code code ..?>
    <TABLE>
     <TR>
      <TD width=50%> <!-- other TD's with more data exist -->
       <DIV> <!-- Below this line is from another dynamically created file -->
        <TABLE WIDTH=100%>
         <TBODY>
          <TR>
           <TD> <!-- other TDs even with more data exist -->
            <DIV>
             <OL><?PHP code that echoes the following LIs from a DB ?>
               <LI> <!-- I want this LIs to fill text up to assigned width and then use ellipsis -->
              </LI>
             </OL>
           </DIV>
         </TD>
    ....

如果我使用 CSS:

  list-style-position:inside;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;  

这将使 LI 的所有内容都通过屏幕,一行很长。 如果我不使用这个 CSS,那么 LI 会很好地多行化(我当然不想要)。

如果我更改父 DIV 或父 OL 的“WIDTH”,则 LI 中的文本会被截断,但仍会用空格填充全文将占据的所有空间。

更新:这里是 jsfiddle:https://jsfiddle.net/Fotofobia/kgrccckc/

有什么建议吗?

提前致谢。

最佳答案

添加以下代码更新。通过这样做,您将创建一种舞台,所有“生活”在其中的内容现在都可以看到 nowrap 和 overflow 规则。我想这会奏效。请告诉我一些事情! :)

list-style-position:inside;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis; 

// Add this to your code
width: 100%;
table-layout: fixed;

关于html - 使省略号在 LI 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44379212/

相关文章:

html - 添加第二行 float 子项时容器 div 更改宽度

html - 将文本突出显示限制在 <pre> block

html - Internet Explorer 9 包裹在 div 表中,其中包含输入、选择/取消选择错误

从 google colab 中的共享 google drive 链接下载数据

包裹 <ul> 上的 CSS 水平线

javascript - 如何使用 javascript 在数组中创建 li 和标签

html - 有什么办法可以将渐变背景转换为 "border-left"吗?

html - 如何将父 div 宽度限制为最小子宽度?

javascript - webkit 掩码图像抛出一个 cors 错误 Angular

php - 如何在 MySQL 数据库中保留 HTML 格式?