Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android/webkit text-overflow: ellipsis not working

i am trying to get the following code to work on an androind 2.1 phone (HTC Sense UI):

h1 {
    font-size: 14px;
    font-weight: bold;
    color: #FFF;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;   
}

however, the text-overflow property does not seem to work. has anybody else had this problem, or found a way to work around it?

like image 289
zimpff Avatar asked Oct 27 '10 18:10

zimpff


2 Answers

on Android 2.2 and 4, I use a line height greater than the font size (always em) with a display type "-webkit-box" and a vertical orientation.

Here is an example:

.myClass{
display     : -webkit-box;
-webkit-box-orient  : vertical;
text-overflow   : ellipsis;
-webkit-line-clamp  : 3;
overflow        : hidden; 
font-size       : 0.9em;
line-height     : 1.2em;
}
like image 173
CJAgile Avatar answered Sep 22 '22 00:09

CJAgile


I see you have no width defined. If the element is allowed to get arbitrarily wide there is never going to be any overflow >within> the element. The element overflowing its parent wil not give you the desired effect.

like image 42
martijnve Avatar answered Sep 20 '22 00:09

martijnve