com.vaadin.flow.dom.Element.getStyle()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(295)

本文整理了Java中com.vaadin.flow.dom.Element.getStyle()方法的一些代码示例,展示了Element.getStyle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getStyle()方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:getStyle

Element.getStyle介绍

[英]Gets the style instance for managing element inline styles.
[中]获取用于管理元素内联样式的样式实例。

代码示例

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Gets the style instance for managing inline styles for the element of
  3. * this component.
  4. *
  5. * @return the style object for the element, not <code>null</code>
  6. */
  7. default Style getStyle() {
  8. return getElement().getStyle();
  9. }

代码示例来源:origin: com.vaadin/flow-server

  1. @Override
  2. public void removeAttribute(Element element) {
  3. element.getStyle().clear();
  4. }
  5. }

代码示例来源:origin: com.vaadin/flow-server

  1. @Override
  2. public boolean hasAttribute(Element element) {
  3. return element.getStyle().getNames().findAny().isPresent();
  4. }

代码示例来源:origin: com.vaadin/vaadin-split-layout-flow

  1. private void setInnerComponentStyle(Component innerComponent,
  2. String styleName, String value) {
  3. Optional.ofNullable(innerComponent).ifPresent(component -> component
  4. .getElement().getStyle().set(styleName, value));
  5. }
  6. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. *
  3. * Gets the width defined for the component.
  4. * <p>
  5. * Note that this does not return the actual size of the component but the
  6. * width which has been set using {@link #setWidth(String)}.
  7. *
  8. * @return the width which has been set for the component
  9. */
  10. default String getWidth() {
  11. return getElement().getStyle().get(ElementConstants.STYLE_WIDTH);
  12. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Gets the max-height defined for the component.
  3. * <p>
  4. * Note that this does not return the actual size of the component but the
  5. * max-height which has been set using {@link #setMaxHeight(String)}.
  6. *
  7. * @return the max-height which has been set for the component
  8. */
  9. default String getMaxHeight() {
  10. return getElement().getStyle().get(ElementConstants.STYLE_MAX_HEIGHT);
  11. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Gets the height defined for the component.
  3. * <p>
  4. * Note that this does not return the actual size of the component but the
  5. * height which has been set using {@link #setHeight(String)}.
  6. *
  7. * @return the height which has been set for the component
  8. */
  9. default String getHeight() {
  10. return getElement().getStyle().get(ElementConstants.STYLE_HEIGHT);
  11. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Gets the min-height defined for the component.
  3. * <p>
  4. * Note that this does not return the actual size of the component but the
  5. * min-height which has been set using {@link #setMinHeight(String)}.
  6. *
  7. * @return the min-height which has been set for the component
  8. */
  9. default String getMinHeight() {
  10. return getElement().getStyle().get(ElementConstants.STYLE_MIN_HEIGHT);
  11. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. *
  3. * Gets the max-width defined for the component.
  4. * <p>
  5. * Note that this does not return the actual size of the component but the
  6. * max-width which has been set using {@link #setMaxWidth(String)}.
  7. *
  8. * @return the max-width which has been set for the component
  9. */
  10. default String getMaxWidth() {
  11. return getElement().getStyle().get(ElementConstants.STYLE_MAX_WIDTH);
  12. }

代码示例来源:origin: com.vaadin/flow-data

  1. private static void setVisible(HasText label, boolean visible) {
  2. if (visible) {
  3. label.getElement().getStyle().remove("display");
  4. } else {
  5. label.getElement().getStyle().set("display", "none");
  6. }
  7. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. @Override
  2. public void add(Component... components) {
  3. Arrays.stream(components).forEach(component -> component.getElement().getStyle().set("flex-shrink", "0"));
  4. menu.add(components);
  5. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. *
  3. * Gets the min-width defined for the component.
  4. * <p>
  5. * Note that this does not return the actual size of the component but the
  6. * min-width which has been set using {@link #setMinWidth(String)}.
  7. *
  8. * @return the min-width which has been set for the component
  9. */
  10. default String getMinWidth() {
  11. return getElement().getStyle().get(ElementConstants.STYLE_MIN_WIDTH);
  12. }

代码示例来源:origin: com.vaadin/flow-component-demo-helpers

  1. private Element getSpacer() {
  2. Element spacer = ElementFactory.createDiv();
  3. spacer.getStyle().set("marginTop", "10px");
  4. return spacer;
  5. }
  6. }

代码示例来源:origin: com.vaadin/incubator-tooltip-flow

  1. /**
  2. * Default constructor.
  3. */
  4. public Tooltip() {
  5. getElement().getStyle().set("margin", "0px");
  6. }

代码示例来源:origin: com.vaadin/flow-server

  1. @Override
  2. public String getAttribute(Element element) {
  3. if (!hasAttribute(element)) {
  4. return null;
  5. }
  6. Style style = element.getStyle();
  7. return style.getNames().map(styleName -> {
  8. return StyleUtil.stylePropertyToAttribute(styleName) + ":"
  9. + style.get(styleName);
  10. }).collect(Collectors.joining(";"));
  11. }

代码示例来源:origin: com.vaadin/flow-server

  1. @Override
  2. public void setAttribute(Element element, String attributeValue) {
  3. Style style = element.getStyle();
  4. style.clear();
  5. parseStyles(attributeValue).forEach(style::set);
  6. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public PaperTab(String caption, Icon icon) {
  2. setId("my-paper-tab");
  3. add(icon);
  4. setText(caption);
  5. getElement().getStyle().set("font-size", "var(--app-layout-font-size-app-bar)");
  6. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public RoundImage(String icon, String width, String height) {
  2. super(icon, "Icon");
  3. setWidth(width);
  4. setHeight(height);
  5. getElement().getStyle().set("border-radius", "100%");
  6. setId("menu-header-image");
  7. }
  8. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public AppMenuIconItem() {
  2. setWidth("100%");
  3. setHeight("var(--app-layout-menu-button-height)");
  4. getElement().getStyle().set("line-height", "var(--app-layout-menu-button-height)");
  5. getElement().addEventListener("click", domEvent -> {
  6. if (this.listener != null) {
  7. this.listener.onComponentEvent(new ClickEvent<>(this));
  8. }
  9. });
  10. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public AppLayoutRouterLayout() {
  2. appLayout = createAppLayoutInstance();
  3. setLayoutToSession();
  4. getContent().add(appLayout);
  5. getContent().setSizeFull();
  6. getContent().getElement().getStyle().set("overflow", "auto");
  7. }

相关文章