I have a div with a specific height and overflow set to hidden. If there are anchors in the overflow content, the visible content of the div will shift, which means that the content I want to show will be shifted from the top of the div, and the anchor will move to the center of the visible part of the div, No scrollbars (good thing), so the content not stuck there.
HTML
<div class="container"> <div class="show-content">Click in the box and hit tab</div> <div class="overflow-content"> <a href="javascript:void(0);">Pesky Link</a> <a href="javascript:void(0);">Pesky Link 2</a> </div> </div>
CSS
.container{ height: 100px; overflow: hidden; border: 1px solid black; } .show-content{ line-height: 100px; height: 100px; font-size: 16px; } .overflow-content a{ display: block; margin-top: 40px; line-height: 20px; font-size: 16px; }
Here is the fiddle. Click inside the field and click the tab to see what I mean http://jsfiddle.net/2seLJ/1/
My use for this is that I have a drop-down menu with links that I want to show only when the user clicks the "show drop-down menu" button. Visible content has an input field, therefore, if user tabs from the input window show links, and there is no way to return to the input window, which does not contain tabs throughout the page. Can this be solved by adding tabindex = "- 1" to all links?
Joeyp source share