作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对需要滚动的应用程序布局和 View 有一个奇怪的问题:
如果我使用默认的应用程序布局创建一个应用程序,则抽屉切换位于顶部,我添加了一个全尺寸的 VerticalLayout 作为 View ,一切都按预期工作。但是,如果垂直内容超过浏览器窗口的高度(即使我将此内容放入滚动条),整个 View 将滚动并在切换后消失,直到达到切换的高度,而不是滚动停止。
它接缝setHeight(100, Unit.Percentage)
不考虑切换的高度。
有人有类似的问题吗?
编辑
将以下代码作为 View 放入 AppLayout 并在您的移动设备上打开它,例如iPhone,您将看到垂直滚动条:
@Route(value = "application/test", layout = ApplicationLayout.class)
@PageTitle("Test")
@RolesAllowed({"ROLE_NEWSLETTER_ADMIN", "ROLE_ORGANIZATION_ADMIN"})
public class TestView extends VerticalLayout implements BeforeEnterObserver {
private MenuBar menu;
private Grid<Person> grid;
private Label footerLabel;
public TestView() {
this.setSizeFull();
menu = new MenuBar();
menu.addItem("New");
menu.addItem("Edit");
menu.addItem("Delete");
this.add(menu);
grid = new Grid<>(Person.class);
this.add(grid);
this.expand(grid);
footerLabel = new Label("Number of objetcs: #");
this.add(footerLabel);
}
@Override
public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {
}
}
应用布局:
public class ApplicationLayout extends AppLayout implements AfterNavigationObserver {
private ApplicationService applicationService;
private H1 headerTitle;
public ApplicationLayout(ApplicationService applicationService) {
this.applicationService = applicationService;
createHeader();
createDrawer();
this.setPrimarySection(Section.DRAWER);
}
private void createHeader() {
// Define the header
HorizontalLayout header = new Header(new H1("Header"));
addToNavbar(header);
}
private void createDrawer() {
....
}
}
最佳答案
It seams that setHeight(100, Unit.Percentage) does not considers the height of the toggle.
VerticalLayout vLayout = new VerticalLayout();
Button button = new Button();
button.setHeight(50, Unit.Pixels);
HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setHeight(100, Unit.Percentage);
vLayout.add(button,hLayout);
这将产生 vLayout 高度大于视口(viewport)高度和滚动条出现的东西。相反,你应该这样做。
VerticalLayout vLayout = new VerticalLayout();
Button button = new Button();
button.setHeight(50, Unit.Pixels);
HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setHeight(200, Unit.Pixels);
vLayout.add(button,hLayout);
vLayout.expand(hLayout); // or vLayout.setFlexGrow(1.0d, hLayout);
关于vaadin - Vaadin 21 和 ApplicationLayout 上的滚动问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69483982/
请引用this question了解我正在尝试做什么。唯一的异常(exception)是我使用的是 ApplicationLayout,我想要 PlaceBar 下面的工具栏。有没有办法欺骗 CSS
我对需要滚动的应用程序布局和 View 有一个奇怪的问题: 如果我使用默认的应用程序布局创建一个应用程序,则抽屉切换位于顶部,我添加了一个全尺寸的 VerticalLayout 作为 View ,一切
我是一名优秀的程序员,十分优秀!