浏览器中没有垂直滚动
我正在开发一个 Vaadin 应用程序,并且很难按照我想要的方式获得布局的某些方面。现在的主要问题是,无论内容有多大或浏览器窗口有多小,我似乎都无法在布局中获得垂直滚动。
我已经阅读了该主题,我知道hLayout 和 vLayout 不支持滚动条,但 Panel 支持。我尝试了许多不同的组合来使其工作,但我只设法生成水平滚动条,但从未生成垂直滚动条。
另一个问题是我正在公司提供的现有“模板”内构建应用程序。该模板包含一个包含一些版权信息的页脚。对于我要添加的内容,此页脚似乎没有占用浏览器窗口中的任何空间,这导致在较小的屏幕上查看时,水平滚动条出现在页脚“下方”,不可访问......我'将提供一些现在看起来如何的代码。
public class InventorySimCardTable extends M2MViewBase { //M2MViewBase extends VerticalLayout
private final SPanel mainContent = Cf.panel("");
private final SPanel tabPanel = Cf.panel("");
private final SVerticalLayout tabcontent = Cf.vLayout();
protected InventoryFilterPanel inventoryFilterPanel;
@Override
protected void initComponent() {
setSizeFull();
tabPanel.setSizeFull();
tabPanel.getContent().setSizeUndefined();
Table simCardTable = new Table();
simCardTable.setWidth("1898px");
simCardTable.setPageLength(15);
tableContainer.setSizeUndefined();
tableContainer.addComponent(simCardTable);
mainContent.setWidth("99%");
mainContent.setHeight("100%");
mainContent.setContent(tableContainer);
mainContent.setScrollable(true);
centeringlayout.setSizeFull();
centeringlayout.addComponent(mainContent);
centeringlayout.setComponentAlignment(mainContent, Alignment.MIDDLE_CENTER);
tabPanel.addComponent(centeringlayout);
addComponent(tabPanel);
}
}
我很想知道是否有人在我的代码中发现任何明显的错误。如果有人知道我可以在页脚 CSS 上设置什么属性,让它占据内容视图中的空间,这样水平滚动就不会出现在它的下面。谢谢你!
I'm developing a Vaadin application and am having extreme difficulty getting some aspects of the layout as I want. The major problem right now is that I can't seem to get a vertical scroll in my layout no matter how big the size of the content is or how small the browser window is..
I have read up on the subject, I know that the hLayout and the vLayout doesn't support scrollbars but the Panel do. I've tried in many different combinations to make it work but I've only managed to get a horizontal scrollbar to generate but never a vertical one.
Another problem is that I'm building the application inside an existing "template" provided by the company. This template contains a footer containing some copyright information. This footer doesn't seem to occupy any space in the browser window with regards to the content I'm adding, which causes when viewing on smaller screens the horizontal scrollbar to appear "underneath" the footer, non-accessible... I'll provide some of the code of how it looks now.
public class InventorySimCardTable extends M2MViewBase { //M2MViewBase extends VerticalLayout
private final SPanel mainContent = Cf.panel("");
private final SPanel tabPanel = Cf.panel("");
private final SVerticalLayout tabcontent = Cf.vLayout();
protected InventoryFilterPanel inventoryFilterPanel;
@Override
protected void initComponent() {
setSizeFull();
tabPanel.setSizeFull();
tabPanel.getContent().setSizeUndefined();
Table simCardTable = new Table();
simCardTable.setWidth("1898px");
simCardTable.setPageLength(15);
tableContainer.setSizeUndefined();
tableContainer.addComponent(simCardTable);
mainContent.setWidth("99%");
mainContent.setHeight("100%");
mainContent.setContent(tableContainer);
mainContent.setScrollable(true);
centeringlayout.setSizeFull();
centeringlayout.addComponent(mainContent);
centeringlayout.setComponentAlignment(mainContent, Alignment.MIDDLE_CENTER);
tabPanel.addComponent(centeringlayout);
addComponent(tabPanel);
}
}
I would love to know if anyone sees any obvious errors in my code. And if anyone knows what property I can set on the footer CSS to have it occupy space in the content view so that the horizontal scroll doesn't appear underneath it. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
为了解决这个问题,我所做的就是按如下方式构建代码。这将为包含我的过滤器组件和表格的面板创建一个垂直和水平滚动条。希望这可以帮助有类似问题的人。
What I did to solve this issue was to structure the code as follows. This will create a vertical and horizontal scroll bar for the Panel holding my filter component and the table. Hopefully this can help someone with a similar problem.
默认情况下,所有 Vaadin 组件的大小均未定义,因此通常无需调用方法
setSizeUndefined()
。另外,也无需调用 setScrollable(true),因为它仅支持编程滚动的可能性。当我试图了解滚动外观时,我编写了一个简单的布局框架。尝试将此作为主窗口的内容:
您应该在嵌套面板内看到滚动条。但是,如果从
Skeleton
布局中删除setSizeFull()
,那么它的大小不受限制(默认情况下)并且向下增长 - 那么只有整个窗口的滚动条出现。All Vaadin components have size undefined by default, so usually there is no need to call method
setSizeUndefined()
. Also there is no need to callsetScrollable(true)
, because it enables only programmatic scrolling possibility.When I was trying to make a sense of scrolling appearance I wrote a simple skeleton of layout. Try this out as a content of the main window:
You should see scrollbars inside the nested panels. But if
setSizeFull()
is removed fromSkeleton
layout, then it is not limited in size (by default) and grows downwards - then only the scrollbar of the whole window appears.将其添加到您的
styles.css
Add this to your
styles.css
首先尝试通过调用 setScrollable(true) 方法使面板可滚动,但是如果您使用 setSizeFull() 设置一些自定义布局作为该面板的新布局,则这将不起作用。
如果您确切知道您的应用程序将在小屏幕分辨率的设备中打开,您可以简单地为您的“主”/“主”布局设置一些固定的宽度和高度,或者添加一些带有参数的 CSS 样式,例如 min-width: {某个值} px,最小高度:{某个值} px。
First of all try to make your panel scrollable by calling setScrollable(true) method, but this will not work if you set some custom layout with setSizeFull() as this panel new layout.
If you exactly know that you application will be opened in device with small screen resolution, you simple can set for your "primary"/"main" layout some fixed width and height, or add some CSS style with params like min-width: {some value} px, min-height: {some value} px.
基于这篇文章,我添加了
vertical.setSizeUndefine();
并开始看到垂直滚动条。Based on this post, I added
vertical.setSizeUndefined();
and started seeing vertical scrollbars.我现在解决这个问题的唯一方法(v6.8.14)是以 px 值指定高度而不是 %
The only way I could fix this now (v6.8.14) is to specify the height in px values in stead of %
始终使用 CustomLayout。它更快、更高效,并且通过轻松控制 html 和 css,您可以获得图形上一致的结果
Use CustomLayout, always. It's faster, more efficient and by controlling html and css easily you can acieve a graphically consistent result