.logo {
display: block;
width: 200px;
height: 100px;
margin: auto;
text-indent: 999px;
font-size: 14px;
font-weight: 500;
color: #F44336;
}Run Code Online (Sandbox Code Playgroud)
<h1 class="logo">This is a title </h1>Run Code Online (Sandbox Code Playgroud)
如果我为text-indent( text-indent: 999px;)分配一个非常大的数字,则仅隐藏第一个单词。在这种情况下,应该隐藏所有单词,因为The text-indent property specifies the indentation of the first line in a text-block.
我不是想隐藏所有的文字。我知道文本缩进图像替换方法。我只是好奇为什么代码不能正常工作。
我发现如果 html 元素的 css 正确使用“文本对齐”,那么文本缩进不起作用,在这种情况下
text-align:unset;
Run Code Online (Sandbox Code Playgroud)