2

how text overflow end with the dots in css2? Design that i done is as follows-

<div class="container">
            <div style="padding-bottom:5px;"><span style="float:left;width:30%;">Address</span><span style="width:2%;">:</span><span style="padding-left:5px;width:60%;"><%#Eval("Address")%></span></div>
            <div style="padding-bottom:5px;"><span style="float:left;width:30%;">City</span><span style="width:2%;">:</span><span style="padding-left:5px;width:60%;"><%#Eval("City")%></span></div>
            <div style="padding-bottom:5px;"><span style="float:left;width:30%;">State</span><span style="width:2%;">:</span><span style="padding-left:5px;width:60%;"><%#Eval("State")%></span></div>
            <div style="padding-bottom:5px;"><span style="float:left;width:30%;">PIN</span><span style="width:2%;">:</span><span style="padding-left:5px;width:60%;"><%#Eval("PostalCode")%></span></div>
    </div>

css is as follows-

.container 
{
    background:#EFF2F7;
    float:left;
    margin:0px 15px 10px 0px;
    border:1px solid #768BB7;
    max-width:23%;
    min-width:22%;
    max-height:120px;
    min-height:100px;
    padding-left:2px;
}

3 Answers 3

11

You can't do it in CSS Level 2 or 2.1. You can only do it in CSS 3. Browser support is good, though, including back to IE6: https://developer.mozilla.org/en/CSS/text-overflow

overflow: hidden;
text-overflow: ellipsis;
Sign up to request clarification or add additional context in comments.

5 Comments

Curiously, Mozilla's own examples don't work for me in Firefox 8.0. Can anyone confirm?
I want to use only css2. Is there any other solution on this?
@Priyanka: "You can't do it in CSS Level 2 or 2.1." It wasn't there back then. Why should you care about which version it was introduced in, anyway? Here's a CSS3 feature that was introduced in IE6 (before CSS3), while my recollection is that there are still one or two CSS2 features with poor browser support. Care about browser support, not when it was introduced into a standard.
@JamWaffles: I'm currently on 7, but if it's the same as 8 (the "ellipsis" example appearing as …345…, that's because the span has a margin-left: -2px, leading to the 12 being ellipsised. Whether or not that's correct behaviour, I don't know. It seems correct to me (overflow should be hidden, so ellipsise at start and end). Also, some things have been changed in Firefox 9.
As far as I know, there isn't such a thing as ".net 2010". Elaborate. If you mean ASP.NET, it only cares for the server side of things, and doesn't in any manner stop you from using CSS 3.
1

just a quick pointer, if you try to use

overflow: hidden;
text-overflow: ellipsis;

on a table, they won't work until you set

table-layout:fixed property on the table tag.

Comments

0

I don't know why you'd want to stick to CSS2, but I'd suggest this:

.container { position: relative; }
.ellipsis  { position: absolute; bottom: 0; right: 0 }

<div class="container">
    Text goes here.
    <div class="ellipsis">...</div>
</div>

Of course, this only gives you a box with three dots in the bottom right corner of your container DIV, but that's as far as you can go without using JavaScript.

2 Comments

I don't want only dots , the overflow of text should be hidden & it should show dots at the end.
Then, just use overflow: ellipsis. It is well-supported, and that's the only thing that matters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.