用css隐藏内容的6个方法

 分类:div+css教程时间:2018-04-03 10:36:28点击:

  最近有个不同行的盆友问我,怎么把内容隐藏起来,我第一想到了用css的方法隐藏起来,我测试了以下这6中方法是可行,欢迎一起交流下,css的其他方法,我们最常用的应该是display:none就行了,其他5种方法好像有seo作弊的嫌疑,虽然能把内容隐藏起来,但我个人感觉正规网站不提倡使用。

用css隐藏内容的6个方法

1.常用的display:none方法

<p style="display:none;">文字看不见</p>

2.文本缩进负值方法

<p style="text-indent:-99999px;">文字看不见</p>

3.文字大小为0方法

<p style="font-size:0">文字看不见</p>

4.width和height为0+防止溢出方法

<p style="width:0;height:0;overflow:hidden;">文字看不见</p>

5.绝对定位负值方法

<p style="position: absolute;left:-6600px;top:-1000px;">文字看不见</p>

6.绝对定位+margin负值方法

<p style="position:absolute;margin-top:-9999px;margin-left:-9999px; ">文字看不见</p>


除注明外的文章,均为来源:老汤博客,转载请保留本文地址!
原文地址: