Reputation: 31378
Why does the following CSS not work?
a {
width: 60px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
Upvotes: 23
Views: 16905
Reputation: 146219
It's for box model, display:block
will do the job
a {
width: 60px;
display:block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
But it may cause you other problems to make the anchor(inline element) behave like box model element (display:block).
Reference: text-overflow
Update:
display:inline-block
Upvotes: 10
Reputation: 6687
It's because anchors are as standard, inline
elements. Adding display:inline-block
will make the above code work.
Upvotes: 37