Hiding an element completly that has had some overflow hidden

这一生的挚爱 提交于 2019-12-02 09:23:34

问题


Basically I have a parent div with height and width and overflow:hidden and then within that some more divs with it. We are dealing with fluid content and some of the divs go over the corners so get hidden. But one is half and half. Is there a way to make that completely hidden?

CSS would be best.


回答1:


I don't think you can know if a child from an overflow:hidden parent is in the hidden or visible section without using Javascript (I might be wrong here).

What I suggest is that you set all the child divs to a fixed dimension d and set the parent div to a multiple of d so every child is either completely visible of not.

This solution won't work if you fill your divs with different-length content




回答2:


If I understand your post, you have a wrapping div that has overflow:hidden and you want to make any child element hidden unless it can be completely displayed within the wrapping div.

There may be a better way to do it, but I would use a CSS media query. If you're unsure of how they work this is a good place to start: http://css-tricks.com/resolution-specific-stylesheets/

Using this method, you could determine how many blocks of each type should be displayed on any given set of resolutions. I'd be interested in seeing how it goes, or if you end up using a different approach. Best of luck!



来源:https://stackoverflow.com/questions/5005402/hiding-an-element-completly-that-has-had-some-overflow-hidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!