# DB2: Dynamic background Image to body

**URL:** https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024
**Category:** Dashboard
**Tags:** dashboard-2
**Created:** [28 June 2024 04:02 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024 "2024-06-28T04:02:09Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)
#### Post date: [28 June 2024 04:02 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/1 "2024-06-28T04:02:09Z")

</div>

Hi everyone  
I'm able to load a dynamic backgound image to a selected widget

```auto
<template>
  <div :style="{ backgroundImage: `url(${this.myimage})` }"></div>
</template>

<script>
  export default {
    data: () => ({
      myimage: "http://192.168.2.251:32400/library/metadata/18131/art/1719252384",
    })
  }
</script>

```

but I do want to have the background on the entire page (in the page behind the widget)

who could help me to update the code ? .. I really suck with this CSS ☹

thx a lot for your help

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [28 June 2024 06:10 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/2 "2024-06-28T06:10:33Z")

</div>

We have an example in the documentation for that: [UI Template Examples | Node-RED Dashboard 2.0](https://dashboard.flowfuse.com/user/template-examples.html#background-image)

No need for any Javascript, you can just define the CSS in a `ui-template`, and change the template type to "CSS (All Pages)" for it to render everywhere.

---

<div class="post-metadata">

### Author: ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)
#### Post date: [28 June 2024 06:40 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/3 "2024-06-28T06:40:12Z")

</div>

yeah .. I had tried that before and now again .. but somehow your sample is not working for me.

I used the exact sample from your reference and have defined below ui-template as CSS for alll pages .. but nothing happens after full rebuild

I'm using lates NR-Beta .4 with dashboard2 (v1.12.2)

I think I miss something ☹

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/6/c68ccb6eb470bca62cc02cfc4eb2a4bff3945b64.png)

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [28 June 2024 06:53 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/4 "2024-06-28T06:53:05Z")

</div>

Hmmm, that seems okay, Ill be at my desk in an hour or so, will double check then!

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [28 June 2024 06:54 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/5 "2024-06-28T06:54:48Z")

</div>

Can confirm that the example code works.  
You may be need to refresh your browser hard, maybe also to clear the cache.  
Also check if you have any errors in browser console.

---

<div class="post-metadata">

### Author: ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)
#### Post date: [28 June 2024 07:14 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/6 "2024-06-28T07:14:40Z")

</div>

that is strange as it does not work with me ☹ .. I have cleared the cache and did a full system restart for docker and my front-end system. I have tried with Chrome & Edge but above code is not showing any pattern in background ... and there is no error in the console ☹

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/140f667463a2c33ddf88e0c498b85a3aceab5c06.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/2111de1e341c456dd8ad71a188509807a5cad615.png)

```auto
[
    {
        "id": "d918d9556a91e86a",
        "type": "ui-template",
        "z": "6e18e178c02e12f4",
        "group": "e60dd6e1af7a9b59",
        "page": "bf1d2c4dc333aad4",
        "ui": "a0ddd2d7af1545fc",
        "name": "back",
        "order": 1,
        "width": "0",
        "height": "0",
        "head": "",
        "format": ".v-main {\n background-image: url(\"https://www.transparenttextures.com/patterns/batthern.png\");\n background-repeat: repeat;\n}",
        "storeOutMessages": true,
        "passthru": true,
        "resendOnRefresh": true,
        "templateScope": "site:style",
        "className": "",
        "x": 730,
        "y": 100,
        "wires": [
            []
        ]
    },
    {
        "id": "e60dd6e1af7a9b59",
        "type": "ui-group",
        "name": "My Group",
        "page": "bf1d2c4dc333aad4",
        "width": "6",
        "height": "1",
        "order": 1,
        "showTitle": true,
        "className": "",
        "visible": "true",
        "disabled": "false"
    },
    {
        "id": "bf1d2c4dc333aad4",
        "type": "ui-page",
        "name": "Test",
        "ui": "a0ddd2d7af1545fc",
        "path": "/test",
        "icon": "home",
        "layout": "flex",
        "theme": "0d7c977402df5308",
        "order": 6,
        "className": "",
        "visible": "true",
        "disabled": "false"
    },
    {
        "id": "a0ddd2d7af1545fc",
        "type": "ui-base",
        "name": "DB2",
        "path": "/dashboard",
        "includeClientData": true,
        "acceptsClientConfig": [
            "ui-notification",
            "ui-control"
        ],
        "showPathInSidebar": false,
        "navigationStyle": "default",
        "titleBarStyle": "default"
    },
    {
        "id": "0d7c977402df5308",
        "type": "ui-theme",
        "name": "Default Theme",
        "colors": {
            "surface": "#ffffff",
            "primary": "#0094ce",
            "bgPage": "#000000",
            "groupBg": "#b8b7b7",
            "groupOutline": "#616161"
        },
        "sizes": {
            "pagePadding": "12px",
            "groupGap": "12px",
            "groupBorderRadius": "4px",
            "widgetGap": "12px"
        }
    }
]

```

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [28 June 2024 07:26 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/7 "2024-06-28T07:26:22Z")

</div>

That is very very odd, I've just sanity checked, and it's working locally for me too (even with your exact flow). Can you right click on the background \> "Inspect".

Then in the Developer Tools, find the `main` element and click it for me. Share a screenshot of what CSS declarations it has on it, it'll look something like this:

 ![Screenshot 2024-06-28 at 08.25.04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be7f2d48ed49829da198b9ea49264520689955e8.jpeg)

---

<div class="post-metadata">

### Author: ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)
#### Post date: [28 June 2024 07:32 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/8 "2024-06-28T07:32:26Z")

</div>

This is from MS Edge

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3d430a832bd22f520bd7a54a4e5c5ba1afcc9e19.png)

---

<div class="post-metadata">

### Author: ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)
#### Post date: [28 June 2024 07:34 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/9 "2024-06-28T07:34:35Z")

</div>

this is from Chrome

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ff8be9b876a2dc7bce374e0cf7e9e3c61afa3377.png)

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [28 June 2024 07:40 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/10 "2024-06-28T07:40:41Z")

</div>

It is strange. If I import your ui\_template - it doesn't work. But it doesn't show any kind of difference from what I have and which works well.

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [28 June 2024 07:42 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/11 "2024-06-28T07:42:35Z")

</div>

Thanks for the screenshots, it's just outright not loading the CSS 🤔

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [28 June 2024 07:44 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/12 "2024-06-28T07:44:33Z")

</div>

I've just switched over to the NR-beta, and can reproduce the problem. Have it breaking on a local system, so I can investigate.

---

<div class="post-metadata">

### Author: ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)
#### Post date: [28 June 2024 07:45 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/13 "2024-06-28T07:45:27Z")

</div>

Yeah ..thats why I shared to code .. icould not find an issue there.. maybe it is something with the theme ..or any other environment setting.. but what ☹

the \>Inspect is not showing the backgound image in ".v-main" as in example from @joepavitt  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f29fff7ba4cc4ee3e2ec013ff4140c12fa4db8a.png)

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [28 June 2024 07:46 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/14 "2024-06-28T07:46:20Z")

</div>

Okay, so I now have it working on the beta, but the solution was an odd one. it didn't work at first, the Editor didn't flag any errors, etc. If I re-selected the `UI` option for the `ui-template`, and then clicked "Done" - it then worked

---

<div class="post-metadata">

### Author: ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)
#### Post date: [28 June 2024 07:46 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/15 "2024-06-28T07:46:26Z")

</div>

damn ..why do I always hit these snags 😉

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [28 June 2024 07:47 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/16 "2024-06-28T07:47:16Z")

</div>

For sure the css is not loaded into the page head  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/0/00724b94e93b74a2cec669918fcdc82fd3763355.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c11e3952581051c54c6da3e279cc3b6defc1d724.png)

`page-back` is not listed. (even if I changed the name)

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [28 June 2024 07:48 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/17 "2024-06-28T07:48:51Z")

</div>

Can I get one more screenshot from you? Can you navigate to `/dashboard/_debug` - hosted wherever your NR server is.

Then click the "Widgets" tab, and search for your "back" node. Expand the widget, and screenshot me the "Properties" please, will look something like this:

 ![Screenshot 2024-06-28 at 08.48.44](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/1/a1b936ee9b0184077dd2d1d2b2c5ddac74c57797.png)

---

<div class="post-metadata">

### Author: ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)
#### Post date: [28 June 2024 08:00 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/18 "2024-06-28T08:00:51Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/5/15b1482bef3e58565dfd81443f2047e2e9f7f54c.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1f0f7f765af9d81a759c7e24d5270a762e5b6b81.png)

---

<div class="post-metadata">

### Author: ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)
#### Post date: [28 June 2024 08:09 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/19 "2024-06-28T08:09:22Z")

</div>

I tried your manual-fix..

- re-selct "UI" option
- "Done"
- "Full Deploy"
- cleared cache

no change for me ☹

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [28 June 2024 08:14 UTC](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024/20 "2024-06-28T08:14:45Z")

</div>

> [@joepavitt](#):
>
> `_debug`

That's fancy tool 😛

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f0277ed1cee8da903c3f9c550b6ef730089364fb.png)

[Next page](https://discourse.nodered.org/t/db2-dynamic-background-image-to-body/89024.md?page=2)
