Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out a better solution for extra scrollbars in IE #3364

Closed
vaadin-bot opened this issue Jan 4, 2013 · 8 comments
Closed

Figure out a better solution for extra scrollbars in IE #3364

vaadin-bot opened this issue Jan 4, 2013 · 8 comments

Comments

@vaadin-bot
Copy link
Collaborator

Originally by @Artur-


IE8-IE10 adds extra scrollbars when a container div with "overflow: auto" contains one or several inline blocks which either
a) contains no text node
or
b) has overflow: hidden

The extra scrollbars in the parent come from extra spacing being reserved by IE below the last inline block. The size of the spacing is relative to the font-size, for a 20px font-size (on the body) the spacing is 6px. Increasing the font-size to 50px increases the spacing to 13px.

The current workaround for this is to define font-size:0 for all v-scrollables which makes the extra spacing 0 and removes the unnecessary scrollbars. To compensate for this all root widget elements (v-widget) define font-size: $font-size, where $font-size is defined for the theme.

This approach makes using em:s and relative (%) font-sizes impossible for the root element in widgets, as these would be relative to the parent element font-size, which is 0. It also makes specifying layout and widget sizes impossible using em:s (percentages work fine) as em:s in sizes are also relative to the parent font-size.

@vaadin-bot
Copy link
Collaborator Author

Originally by @Artur-


Attachment added: ie8-inlineblocks.html (1.3 KiB)
Test demonstrating the issue

@vaadin-bot
Copy link
Collaborator Author

Originally by RalfN


Don't know, if it's helpful, but adding

.box:after {
content: "";
width: 100%;
display: inline-block;
}

removes some of the scrollbars. And FF and chrome don't complain about this.
(found with google)

greetings
Ralf

@vaadin-bot
Copy link
Collaborator Author

Originally by fcracker79


It may be trivial, but one might add the following:

padding-bottom: 0.3em;

to the container class and at least the bar disappears. Maybe it could be included only for Internet Explorer 8, even though this way users may notice different rendering results in IE compared to Firefox.

@vaadin-bot
Copy link
Collaborator Author

Originally by RalfN


Any updates on this one?
There were rumors about a fix in Vaadin 7...

@vaadin-bot
Copy link
Collaborator Author

Originally by @jouni


The new Valo theme currently works around this issue with the following main ingredients:

.v-widget {
  vertical-align: top;
}

.v-scrollable {
  overflow: auto;

  // "Unnecessary scrollbar" related fixes
  > .v-widget {
    // This is needed for IE
    vertical-align: middle;

    // Needed for all browsers. Can't really show anything outside the
    // scrolling area anyway, so we can safely hide any overflow
    overflow: hidden;
  }
}

So far it's looking good, no font-size: 0; or line-height: 0; hacks necessary. But I will not say it's bulletproof just yet. I'll wait for a larger beta test audience to tell me otherwise.

@vaadin-bot
Copy link
Collaborator Author

Originally by santeriv-profit


Jouni, thanks a lot for quick reaction, seems to solve vertical extra scrollbars on IE10 at least.

Here is how I used it with .css in Vaadin 7.2.0

.fix-panel-scrollbars .v-scrollable
{
  overflow: auto;
}

.fix-panel-scrollbars .v-scrollable .v-widget
{
	/* This is needed for IE */
    vertical-align: middle;
    /* Needed for all browsers. Can't really show anything outside the
    scrolling area anyway, so we can safely hide any overflow
    -/
    overflow: hidden;
}

I don't know if this style-fix needs MSIE-only-guard?

and in UI which implements ViewChangeListener

  @Override
  public void afterViewChange(ViewChangeEvent event) {
    fixInternetExplorerScrollbars();
  }

  protected void fixInternetExplorerScrollbars() {
    if(getPage().getWebBrowser().getBrowserApplication().contains("MSIE")) {
      contentVsFooter.addStyleName(FIX_PANEL_SCROLLBARS);
      notificationArea.addStyleName(FIX_PANEL_SCROLLBARS);
      HasComponents mainViewDisplay = (HasComponents) contentVsFooter.getFirstComponent(); 
      List<Panel> panelsInMainViewNow = VaadinTraverser.getChildrenByClass(mainViewDisplay, Panel.class);
      for (Panel panel : panelsInMainViewNow) {
        panel.addStyleName("fix-panel-scrollbars");
      }
    }
  }

@vaadin-bot
Copy link
Collaborator Author

Originally by @jouni


No need for any IE guards, the fix is applied to all browsers in Valo also. The issue affects all browsers, not just IE (at least in Valo to some degree), but for some reason it was only evident in IE with the older themes.

And do use the child combinator (>) in the selector, so that it only affects the direct child inside the scrollable element (and no need to re-apply overflow: auto;, that will come from the main theme). Otherwise all components will get the overflow: hidden; inside the panel, which might not be what you want.

I would say it's pretty safe to just make it into a global fix, but if you absolutely want to scope it with an additional style name, go ahead.

So I would just add this in your theme:

.v-widget {
  vertical-align: top;
}

.v-scrollable > .v-widget {
  vertical-align: middle;
  overflow: hidden;
}

Or if you prefer to scope it, then this:

.fix-panel-scrollbars {
  .v-widget {
    vertical-align: top;
  }

  .v-scrollable > .v-widget {
    vertical-align: middle;
    overflow: hidden;
  }
}

@jouni
Copy link
Member

jouni commented Dec 12, 2016

Closing as wontfix, as all old themes will be deprecated in version 8. You can use the documentation workarounds in this issue for your custom themes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants