Polymer: Is it possible to add media querys and css classes to a template?

Hi, first of all, I’m using polymer for 2 month and I’m quite a noob in frontend development. Idk if html/css allows this kind of flexibility. But I think, it should! - some day…? So please forgive me if this is a stupid question.

So, what I wanne do: I want to manage my target devices from the backend. So, I need to add the “@media screen …” parts from java, like:

getElement().getStyle().add(buildMediaQuery());

Is there a way to do this?

Thanks for your answers,
Lars

Hi Lars. The best way to inject those styles based on backend data would probably be using the PageConfigurator as you want to do it once when for the initial page. You can read https://vaadin.com/docs/v12/flow/advanced/tutorial-bootstrap.html for more details.

Hi Lars,

Perhaps this addon will help you. You can manage your style from backend.

https://vaadin.com/directory/component/mediaquery

Great, this is what I need.

It would be great if it works without a client/server request.