hiding text using “text-indent”

后端 未结 11 2192
北海茫月
北海茫月 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:27

      My problem was with text-align. In case you modify align mode of the element or parent element(s) wrapping it to left, you must give a negative index for text-indent. Otherwise you must give a positive value.

      .case1{text-indent:-999px;text-align:left;overflow:hidden;display:block}
      

      Otherwise

      .case2{text-indent:999px;text-align:right;overflow:hidden;display:block}
      

    提交回复
    热议问题