hiding text using “text-indent”

2019-03-25 04:33发布

I'm trying to hide some text inside an <li> element using CSS by setting text-indent: -999px;.
For some reason this doesn't work when I set the direction of the document to "rtl" (right to left - my site is in Hebrew).
When direction is "rtl" the text still shows...
Anyone knows why, and a way around this?

10条回答
姐就是有狂的资本
2楼-- · 2019-03-25 05:23

Try setting text-alignment to match the direction in which you are indenting text.

For example, if you use LTR and want to indent text negatively, besides adding display: block, you should also add left alignment.

Not sure for RTL, but seems logical you should indent it positively and use right alignment.

查看更多
不美不萌又怎样
3楼-- · 2019-03-25 05:23
color: transparent;

or

font-size:0px;
查看更多
Evening l夕情丶
4楼-- · 2019-03-25 05:26

The text-indent: -99px is an old trick, which is not the optimal way to hide text. Why not use visibility:hidden instead?

查看更多
趁早两清
5楼-- · 2019-03-25 05:29

You can use line-height specifying a large value, say 100px for a 30px high container.

only works if your container is limited in size. you may have to specifically set height if it isn't yet.

查看更多
登录 后发表回答