css - 布局不可滚动

标签 css sass vaadin

我正在使用 Vaadin/Spring boot 设计一个应用程序,我已经设法使用位于 styles.scss 文件(根据 Vaadin 在 myTheme 中)中的以下 css 设置我的应用程序的背景:

.backgroundImage{

      background: url("img/background4.png") ;
    min-height: 100%;
    width: 100%;
    position: fixed;
    top:0;
    left: 0;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;

    }

它按照锡 jar 上的说明进行操作,它设置背景图像。我的问题是这使得页面不再能够滚动,这是我的一个表单的图片:enter image description here .

有谁知道我哪里出错了?此外,我真的很想将此背景设置为我的应用程序的默认背景。任何人都可以建议如何执行此操作吗?

我将 CSS 更改为:

  .backgroundImage{

    background: url("img/background4.png") no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
  }

按照 Mo 的指示,但我现在得到 37 像素的填充?类构造函数如下所示:

 public AddEmployeeView() {
        GridLayout grid = new GridLayout(3,2);
        setSizeFull();
        setStyleName("backgroundImage");
        setMargin(false);
        setDefaultComponentAlignment(MIDDLE_CENTER);
        addComponent(aUI.getHeader());
        header.addStyleName("h2");
        addComponent(header);
        Panel topleft = topLeftAndBottom();
        Panel topright = topRight();
        grid.setSizeUndefined();
        grid.addComponent(topleft,0,0,0,1);
        grid.addComponent(topright,1,0,1,1);
        addComponents(grid,generateButtons());

    }

enter image description here

最佳答案

使用这个CSS:

.backgroundImage{

    background: url("img/background4.png") no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

编辑

如果您希望背景 img 覆盖所有应用程序,只需将上面的样式应用到 bodyhtml 并将该样式放入 Global styles

Global styles are styles defined in the document scope. Global styles can target document body and any regular DOM contents inside, including the application views

关于css - 布局不可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50426528/

相关文章:

html - 如何实现具有正 z-index 的多步进度条?

css - 切换 scss 变量文件

使用Spring Boot + Vaadin Spring时Vaadin Sass "on-the-fly"编译

html - 外壳内的响应式搜索框和元素

jquery - 谷歌浏览器中的粘滞条忽略 z-index

reactjs - 样式表没有设置 React 组件的样式

Vaadin Grid ItemClickListener 无法使用 ImageRenderer 注册对列的点击

vaadin - Component.setVisible() 方法如何工作?

ruby-on-rails - 用于 haml 页面的 Ruby/Rails 绑定(bind) css

css - 如何仅更改一个选项卡的颜色 GtkNotebook