css隐藏内容的方法有三种:即display:none、visibility:hidden、overflow:hidden。

  1.display:none;的缺陷:

  搜索引擎可能认为被隐藏的文字属于垃圾信息而被忽略

  屏幕阅读器(是为视觉上有障碍的人设计的读取屏幕内容的程序)会忽略被隐藏的文字。

  

  2.visibility: hidden ;的缺陷:

  隐藏的内容会占据他所应该占据物理空间。

 

  3.overflow:hidden;一个比较合理的方法

  .texthidden { display:block; overflow: hidden; width: 0; height: 0; }

  将宽度和高度设定为0,然后超过部分隐藏,就会弥补上述1、2方法中的缺陷,也达到了隐藏内容的目的。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2021-06-26
  • 2021-08-24
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-20
  • 2021-09-07
  • 2021-09-07
  • 2021-12-24
  • 2021-09-07
  • 2021-09-07
相关资源
相似解决方案