Simple thing. I need to use my own background for LoginOverlay in Vaadin 23.
I tried crazy magic with stuff like this
vaadin-login-overlay-wrapper
vaadin-login-backdrop-wrapper
and it did not work.
Create a file vaadin-login-overlay-wrapper.css in frontend/<your theme>/components
Then you can set the background image
:host [part="brand"] {
background-image: url("images/login-banner.jpg");
background-size: cover;
background-position-x: center;
}
Related
We can add a vaadin 14 grid row stripes with the following code.
grid.addThemeVariants(GridVariant.LUMO_ROW_STRIPES);
But it shows background-image in even row and white in odd row. I can see below css:
:host([theme~="row-stripes"]) [part~="row"]:not([odd]) [part~="body cell"],
:host([theme~="row-stripes"]) [part~="row"]:not([odd]) [part~="details-cell"] {
background-image: linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
background-repeat: repeat-x;
}
I want to reverse the color, ie. white in even row and background-image in odd row. How can I achieve it? I tried the following css, but it does not work:
:host([theme~="row-stripes"]) [part~="row"]:not([even]) [part~="body-cell"],
:host([theme~="row-stripes"]) [part~="row"]:not([even]) [part~="details-cell"] {
background-image: linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
background-repeat: repeat-x;
}
Thanks in advance.
I think you need to override the existing background image on the even rows as well.
So you can do something like this
:host([theme~="row-stripes"]) [part~="row"]:not([odd]) [part~="body-cell"],
:host([theme~="row-stripes"]) [part~="row"]:not([odd]) [part~="details-cell"] {
background-image: none !important;
background-repeat: repeat-x;
}
:host([theme~="row-stripes"]) [part~="row"]:not([even]) [part~="body-cell"],
:host([theme~="row-stripes"]) [part~="row"]:not([even]) [part~="details-cell"] {
background-image: linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
background-repeat: repeat-x;
}
Note that these styles should be placed in a style sheet that targets the shadow dom of the Grid. If you are using the custom-themeing mechanism, then the above styles should be placed under frontend/themes/<custom-theme-name>/components/vaadin-grid.css.
I'm trying to set a background image for a class.
This is my file structure using laravel-mix:
What's wrong with my code in app.scss file?
.header-bg {
background-image: url('img/illustration-main.jpg');
background-size: cover;
}
Tried this but also not working:
.header-bg {
background-image: url(require('img/illustration-main.jpg'));
background-size: cover;
}
Here in case the content of the img folder:
If your css file is being built to dist/app.css your image path should be relative to this. Since your img folder is sibling to dist, try url('../img/illustration-main.jpg')
I have an image in the assets/images and I want to set it as a background on the main page refers to a given class, but I do not see image in production Heroku
application.scss
.has-bg-img { background: url('img.PNG'); center center; background-size:cover; }
In my Rails app, I change the filename to end with .scss.erb and then have the following as an example. A comment at the top, followed by the example.
//= depend_on_asset "sprite-article-r4.svg"
.contents {
background-image:url('<%= asset_path("sprite-article-r5.svg") %>');
}
Reference this SO question
you must set a full path like url('localhost/apps/assets/images/myimg.jpg')
If your assets are not static and committed into your repo, and you're trying to reference a dynamically uploaded image, you might have to read on how to work around with Heroku's ephemeral filesystem
You can try image-url or asset-url helpers.
Asset Pipeline
Edit :
actually, i'm not sure about your syntax
.has-bg-img {
background-image: url('img.PNG');
background-position: center center;
background-size:cover;
}
it should work better.
In Rails, you have to prepend directory name to url. For your case change
.has-bg-img { background: url('img.PNG'); center center; background-size:cover; }
to
.has-bg-img { background: image-url('img.PNG'); center center; background-size:cover; }
This is because you are storing your image in images(assets/images) directory.
Try to the following
.has-bg-img {
background-image: asset-url('img.png');
background-size: cover;
}
This should work, I don't why you use center center; I think that is syntactically invalid see this Horizontal & Vertical Align
I have a bunch of svg's I am placing as background images. I'm looking for a way to create a partial path with a variable and then pass just the file name into my mixin. Something like this:
#url: "url('../images/icons/_mm/";
.bg(#fileName){
background-image:#url #fileName;
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
Unfortunately this doesn't concatenate correctly. When I pass in an argument like this:
.mmWrap{
.bg('swoosh.svg');
}
the resulting css is this:
.mmWrap {
background-image: "url('../images/icons/_mm/" 'swoosh.svg';
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
...a mess. And the LESS compiler throws an error if I try to pass the argument without quotes. I know the answer may involve the escape ~ string, but I'm all out of ideas. Can anyone help out here? Thanks in advance!
To do something like that you'd have to resort to string interpolation..
#image_dir: '../images/';
.bg(#filename) {
background-image: url('#{image_dir}#{filename}');
}
This is the only way I know of using LESS. Hope this helps!
I have got set in CSS that some image is background, and when it is over with I want to repeat or I want to continue with other image
something like this:
ul.smenu .menu_tlacidlo:hover {
background:url(images/sluzby_menu_btn_hover_2.png);
background-repeat: "url(images/sluzby_menu_btn_line.png)";
width:142px;
height: 22px;
}
Is there way to do it?