CSS 我想隐藏 <span> 中的文本。但为什么它不起作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2592407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:52:33  来源:igfitidea点击:

I want to hide text which is in <span> . but why it's not working?

cssxhtml

提问by Jitendra Vyas

I want to hide text which is in <span>. but why it's not working?

我想隐藏<span>. 但为什么它不起作用?

.pdf {text-indent: -9999}

<p>
   <a href="reader_overview.pdf" title="Open in a new Window" target="_blank"><img src="pdf.gif" alt="PDF" width="16" height="16" />
   <span class="pdf">PDF 34KB, Opens in a new window</span> </a>
</p>

采纳答案by Quentin

text-align

Applies to: block-level elements, table cells and inline blocks

文本对齐

适用于:块级元素、表格单元格和内联块

http://www.w3.org/TR/CSS2/text.html

http://www.w3.org/TR/CSS2/text.html

Span is, by default, inline.

默认情况下,跨度是内联的。

The value it takes is also a lengthand so requires units if the value is non-zero.

它采用的值也是一个长度,因此如果该值非零,则需要单位。

There seems little point in including the information in the document if you are going to hide it though. I assume you are trying to provide information to screen reader users instead of all users … but that information is as useful to people not using screen readers.

如果您打算隐藏它,那么在文档中包含信息似乎没什么意义。我假设您正在尝试向屏幕阅读器用户而不是所有用户提供信息……但该信息对不使用屏幕阅读器的人同样有用。

回答by Thomas Bonini

Use .pdf {display: none}

.pdf {display: none}

回答by Tomalak

I thought hiding with CSS worked like this:

我认为用 CSS 隐藏是这样工作的:

.pdf {
  display: none;
}

回答by GalacticCowboy

If you want to hide it, use the CSS that is intended for that purpose:

如果要隐藏它,请使用专门用于该目的的 CSS:

.pdf { visibility: hidden; display: none; }

回答by pixeltocode

try this

尝试这个

.pdf {display: block; height: 40px; line-height: 200px;}