我现在深入一些iPhone(Safari / WebKit)的Web应用程序开发,并希望具有标题文字和正文文本的高度项目,以便始终显示3行。如果标题文本很短,则应显示2行正文。如果标题文本很长,最多应该占用2行,并为身体文本留下1行。每当文本被截断时,它应该显示一个省略号作为最后一个字符。
我已经提出了以下的一切,除了它不显示省略号,我需要的一切。有没有办法得到这个解决方案来满足最后的要求?
Code below,as rendered by Safari http://segdeha.com/assets/imgs/stack-ellipsis.png
<!DOCTYPE HTML> <html> <head> <style type="text/css"> #container { width: 100px; } p { /* white-space: nowrap; */ font-family: Helvetica; font-size: 12px; line-height: 16px; text-overflow: ellipsis; max-height: 48px; overflow: hidden; border: solid 1px red; } strong { /* white-space: nowrap; */ font-size: 16px; display: block; text-overflow: ellipsis; max-height: 32px; overflow: hidden; } </style> </head> <body> <div id="container"> <p> <strong>Short title</strong> This is the text description of the item. It can flow onto more than 2 lines,too,if there is room for it,but otherwise should only show 1 line. </p> <p> <strong>Long title that will span more than 2 lines when we're done.</strong> This is the text description of the item. It can flow onto more than 2 lines,but otherwise should only show 1 line. </p> </div> </body> </html>