5

I've got some text and I need it to overflow off the left side of its container (I hide the overflow). Basically, I want it to look like this: enter image description here

Apparently, you have to you direction: rtl; to do this. Fiddle here.

The problem is that this changes some of the order of the text: hello, world? is displayed as ?hello, world, and 1+2=3 is displayed as 3=1+2.

I've tried playing with the unicode-bidi property, but I can only get that to put things completely right to left.

So, here's the actual question: How can I get text to overflow off the left side of its container without reordering the text?

1
  • Can you post an example of "expected output" Commented Sep 11, 2011 at 19:01

3 Answers 3

5

Try:

text-align:right;
white-space:nowrap;
overflow:visible;
Sign up to request clarification or add additional context in comments.

5 Comments

Doesn't work. See forked fiddle. Again, the idea is to make the text overflow off the left side, not the right.
If you don't specify the h1 width and make it float right. It will overflow on the left side. Would that be what you are looking for ? jsfiddle.net/6JF9T/3
Ah, I see. That's a good start, thanks. Problem is, I need to hide the overflow text (see parentheses on first line).
The goal isn't to hide the overflow of the parent div, it's to hide the overflow of the h1.
Actually, I just realized that I can add another invisible parent element just for this purpose. So, this works. Thanks!
0

If you have a specific block of text you need to manipulate try the text-indent property with a negative value like so:

text-indent: -20px

This probably won't work for dynamic text though.

Comments

0

You will need to wrap the English text into a span which has direction LTR, and the overflowed text has "inline-flex" like the following:

<div style="direction:rtl;width:150px;overflow:hidden;text-align:right;white-space:nowrap;">
    <div style="display:inline-flex">
        <span style="direction:ltr;">Hello people, I'm asking: 1+1=2, or what???</span>
    </div>
</div>

You will get: http://codepen.io/anon/pen/xKfGa

It is some how complicated, but I think this is the only right way, although it won't display perfectly on IE.

Comments

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.