hiding text using “text-indent”

后端 未结 11 2182
北海茫月
北海茫月 2021-02-13 11:26

I\'m trying to hide some text inside an

  • element using CSS by setting text-indent: -999px;.
    For some reason this doesn\'t work when I set
  • 相关标签:
    11条回答
    • 2021-02-13 11:44

      What about setting direction:ltr on the elements you're trying to give negative text-indent?

      Demo: jsfiddle.net/Marcel/aJBnN/1/

      0 讨论(0)
    • 2021-02-13 11:45

      text-align: right; works for me

      0 讨论(0)
    • 2021-02-13 11:48

      Along with text-indent: -9999px try using display: block;. It solved for me.

      Additionally, if you need the li elements to float horizontally (e.g. a horizontal menu), use float: left;.

      0 讨论(0)
    • 2021-02-13 11:52

      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.

      0 讨论(0)
    • 2021-02-13 11:53

      Add overflow hidden then it will work fine.

      div{
          text-indent: 100%;
          overflow: hidden;
      }
      <div>
       search
       <input type="text">
       </div>

      0 讨论(0)
    提交回复
    热议问题