【问题标题】:How to style individual slots in a Vaadin GridLayout?如何在 Vaadin GridLayout 中设置各个插槽的样式?
【发布时间】:2017-03-16 10:02:59
【问题描述】:

我想在我的 GridLayout 中的某些插槽上设置边框。 如果我在插槽内的元素上设置边框(借助样式名称),则边框不会一直绘制。

如何访问封闭的 gridlayout-slot,以便每个其他插槽都有边框?

【问题讨论】:

    标签: sass vaadin vaadin-grid


    【解决方案1】:

    我建议你在 GridLayout 中放置一个 CssLayout 和这样的样式:

    final GridLayout gridLayout = new GridLayout(2, 2);
    // the size of the grid layout has to be defined, otherwise you can't place a relatively sized component inside it
    gridLayout.setHeight("400px"); // example height
    gridLayout.setWidth("100%"); // example width
    
    final CssLayout border = new CssLayout();
    border.setStyleName("myCellStyle");
    // make the layout fill the whole slot
    border.setSizeFull();
    // wrap your content with that border layout
    border.addComponent(new Label("forth"));
    gridLayout.addComponents(
                new Label("first"), 
                new Label("second"),
                new Label("third"),
                border);
    

    在你的 mytheme.scss 中写下你的边框样式:

    .myCellStyle {
      border: 10px solid red;
    }
    

    【讨论】:

      猜你喜欢
      • 2023-02-15
      • 1970-01-01
      • 2020-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-17
      • 1970-01-01
      • 2022-12-17
      相关资源
      最近更新 更多