How to add an Background to my app

0
Hey, I want to add an Image and use it as my background but I cant figure out how to do this. I already read that I have to use the layout.css but I cant find it.
asked
3 answers
3

Hi Christopher,

You can compile the scss file using simple koala compiler. I Hope this documentation will help you to achieve it 

https://docs.mendix.com/howto6/setup-mendix-ui-framework-with-koala

Thanks

answered
2

Heyho,

as stated by Tim, but there are some small culprits for frustation.

to avoid these

1) If you haven’t d/l this yet: use https://docs.mendix.com/howto/front-end/calypso to compile your css. It makes life easier.

2) When using images in your css, you need to upload them in mendix first. Mendix prepends strings to the image name, eg $appname$path$theimagename.extention.
For instance “bg_dandelion_lightblue.jpg” becomes “JFlowMain$Images$bg_dandelion_lightblue.jpg

(To find the right mendix name I usually place the uploaded image on a page, run it locally and use the inspector in chrome or ff. copy+paste, and remove the image again.)

In your scss your rule will be

background-image: url("/img/JFlowMain$Images$bg_dandelion_lightblue.jpg")

Hope this helps.

answered
0

<project-dir>\theme\styles\web\sass\ui_resources\atlas_ui_resources\layouts\_layout-atlas.scss

But best is to add your modification to <project-dir>\theme\styles\web\sass\app\_custom.scss

.layout-atlas {
    background-image: '..' 
}

then generate the css 

edited:

  • generating css can also be done “sass --watch sass:css” and rerun your project, but Calypso or Koala will make it easier.
  • another easy way to add your background image is to add it as base64-encoded file, like this spinnerwhileloading-image: 
    
    body{
        background: url(data:image/gif;base64,R0lGODlhNgA2APMAAP///wAAAHh4eBwcHA4ODtjY2FRUVNzc3MTExEhISIqKigAAAAAAAAAAAAAAAAAAACH5BAkKAAAAIf4aQ3JlYXRlZCB3aXRoIGFqYXhsb2FkLmluZm8AIf8LTkVUU0NBUEUyLjADAQAAACwAAAAANgA2AAAEyxDISau9OOvNu/9gKI5kySEJQSSI6UqKKhPKWyLz3NpimqsJnug3E4aIMiPI9wsqPTjiTlkwqAwFTCxXexYGs0H2ggJOLYLBQDCy5gwmwYx9JJrAssHQXsKr9CFuM3AlcjJ0IAd+BAMHLmlrJAduBo5Pl5iZmpucnZ6fcWqImJCjaHOZhiqmFIuAl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cbV59nl3cXk4u8oEQA7);
    }
    

    To encode your image use, for instance, https://www.base64-image.de/but I like it better to use Koen’s way and upload the image first. That saves the client the trouble of decoding it first and you actually see the picture in your modeler.

answered