style.visibility和style.display的区别

style.visibility和style.display都可以实现对页的隐藏,但visibility要占用域的空间,而display则不占用
  • 将元素display属性设为 block,会在该元素后换行。
  • 将元素display属性设为 inline,会消除元素换行。
  • 将元素display属性设为 none,隐藏该元素内容,且不占用域的空间。
  • 将元素visibility属性设为 hidden,隐藏该元素内容,但占用域的空间。
  • 将元素visibility属性设为 visible,显示元素内容。

 

<P>欢迎<SPAN style="display:inline">你</SPAN>进入我的博客</P>

效果:欢迎进入我的博客

<P>欢迎<SPAN style="display:block">你</SPAN>进入我的博客</P>

效果:欢迎进入我的博客

<P>欢迎<SPAN style="display:none">你</SPAN>进入我的博客</P>

效果:欢迎进入我的博客

<P>欢迎<SPAN style="visibility:hidden">你</SPAN>进入我的博客</P>

效果:欢迎进入我的博客

<P>欢迎<SPAN style="display:visible">你</SPAN>进入我的博客</P>

效果:欢迎进入我的博客

原文地址:https://www.cnblogs.com/zhenmingliu/p/2506649.html