I have an HTML page that has a <div> that contains content that is wider than itself; the excess becomes invisible with the overflow: hidden style.
There may be links in this content. In IE8 (but not in Firefox 3.6), if you use the keyboard (i.e. the Tab key) to focus on the link cropped to the right edge, IE will scroll the entire div on the left far enough to make the entire link visible. (The same thing happens with links on the left, when they get focus, if the div is already scrolling to the left - it scrolls the contents to the right to show the whole link.)
I can try to hide this unwanted scrolling by setting the scrollLeft value to div when it comes out of the way - jQuery makes it easy. But I would prefer, if possible, to use a style or setting to prevent scrolling in the first place. As already mentioned, Firefox does not view a partially cropped link when it focuses. Ideally, IE should behave the same.
HTML example below. In IE, use Tab (or Shift + Tab) to alternately set the focus on each link to see how the contents of the window shift sideways.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Demo of undesired scrolling</title> </head> <body> <a href="http://www.w3.org">Before</a> <div style="width: 400px; border: 1px solid gray; overflow: hidden;"> <div> <div style="width: 450px; text-align: center;"> <a href="http://www.w3.org">Somewhere in the middle</a> </div> <div style="width: 450px; text-align: left;"> <a href="http://www.w3.org">Over on the left</a> </div> <div style="width: 450px; text-align: right;"> <a href="http://www.w3.org">Over on the right</a> </div> </div> </div> <a href="http://www.w3.org">After</a> </body> </html>
Thanks in advance for your understanding!
source share