如何将divs设置为“visibility:hidden”如果他们在视口外 [英] how can i set divs to "visibility:hidden" if they are outside of viewport
问题描述
我正在开发移动网络应用程序。但是,Safari 5.1或更低版本的Safari Safari的内存有限。我需要最小化内存使用,当我使用css3过渡。我发现,如果我使用css样式显示:无/可见性:隐藏,应用程序不会崩溃内存问题。所以我想做的东西隐藏,当他们真正隐藏。
我的英语不好。图片可以显示我想要的内容:
I am developing mobile web app. However, safari in iOS 5.1 or below has limited memory. I need to minimize the memory usage when i use css3 transition. I found that if I use css style "display:none / visibility: hidden", The app will not crash by memory problem. So I want to make thing "hidden" when they are truly hidden. My English is bad. the picture can show what I want to:
上传的图片**:**
uploaded image**:**
另一个例子是网站使用css :hidden属性来隐藏屏幕上不显示的每个会话:
Another example which is a website used the css "visibility: hidden" property to hide every session when it is not on screen:
推荐答案
有一个 jQuery提供视口选择器的插件。
您可以将所有内容设置为 visibility:hidden;
,然后只显示视口中的项目。一旦用户滚动,您可以重新抓取视口元素并显示它们。
You can set everything to visibility:hidden;
and then show only the items in the viewport. Once the user scrolls you can re-grab the viewport elements and show them too.
$(":in-viewport").css("visibility", "visible")
这篇关于如何将divs设置为“visibility:hidden”如果他们在视口外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!