I have a panel with a inline-blockdiv. Some of them are not viewable, because I installed: white-space:nowrap; overflow: hidden;for the container. I am looking for ways to select the last visible child. By visible, I mean that a div is placed (preferably completely) in the area of ββits container.
As far as I know, such a selector is not used in either CSS or jQuery. The closest is jQuery :visible, but it says that all divs are visible because they consume space in the page layout.
The only way I can see is to list the divs on load and each size to calculate if the div is in the container, adding up its width, padding and margins.
Do you have any better ideas?
#container {
white-space:nowrap;
overflow: hidden;
}
.element {
display: inline-block;
vertical-align:top;
}
<div id="container">
<div class="element">
<img src="http://placehold.it/150x150" alt=""/>
</div>
<div class="element">
<img src="http://placehold.it/150x150" alt=""/>
</div>
<div class="element">
<img src="http://placehold.it/150x150" alt=""/>
</div>
<div class="element">
<img src="http://placehold.it/150x150" alt=""/>
</div>
<div class="element">
<img src="http://placehold.it/150x150" alt=""/>
</div>
<div class="element">
<img src="http://placehold.it/150x150" alt=""/>
</div>
<div class="element">
<img src="http://placehold.it/150x150" alt=""/>
</div>
<div class="element">
<img src="http://placehold.it/150x150" alt=""/>
</div>
</div>
Run codeHide result, 4 div 5-. 5- ( 4- div, ).