Reputation: 121
I'm attempting to get ellipsis working on my site. This is the following HTML / CSS code and it doesn't appear to be working.
CSS:
.oneline {
text-overflow:ellipsis;
white-space: nowrap;
width: 50px;
overflow: hidden;
}
HTML:
<div class="oneline">Testing 123 Testing 456 Testing 789</div>
Upvotes: 5
Views: 22239
Reputation: 19216
Assigning position:absolute
to the element to be truncated will probably have less undesired side-effects that float:left
.
This worked for me:
div {
position: absolute;
width: 70px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Upvotes: 0
Reputation: 77956
Based on the initial post, we're all assuming the obvious, but just in case ... ;)
<style type="text/css">
.oneline {
text-overflow : ellipsis;
white-space : nowrap;
width : 50px;
overflow : hidden;
}
</style>
<div class="oneline">Testing 123 Testing 456 Testing 789</div>
EDIT: Solution was to style the paragraph vs the div.
Upvotes: 11