Search This Blog

Showing posts with label How do I display a page background image in ORACLE APEX. Show all posts
Showing posts with label How do I display a page background image in ORACLE APEX. Show all posts

Sunday, July 13, 2025

How do I display a page background image in ORACLE APEX

 Adding a background image to a page in Oracle APEX can transform the look and feel of your application, helping to brand or visually enrich the user experience. Whether you're applying a subtle texture or a full-screen photo, Oracle APEX makes it easy to set a custom background using CSS. In this blog post, we’ll walk through how to display a page background image in Oracle APEX using built-in features, and how to ensure it scales and performs well across different devices.How to Display a Page Background Image in Oracle APEX

  1. Upload the Background Image to Static Files

    • Go to Shared Components → Static Application Files

    • Click Upload File and choose your image file (e.g., background.jpg)

    • After uploading, note the file URL (right-click the file and copy link)

  2. Add CSS to Reference the Background Image

    • Navigate to the target page

    • Click Page → CSS → Inline and add the following CSS:

      body {
        background-image: url('#APP_IMAGES#background.jpg');
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center center;
        background-attachment: fixed;
      }
      
    • Replace background.jpg with your actual file name if different

  3. Optional: Apply Background to Specific Page Elements
    If you want the background image to apply only to a specific region or container:

    #t_Body {
      background-image: url('#APP_IMAGES#background.jpg');
      background-size: cover;
      background-repeat: no-repeat;
    }
    
  4. Preview the Page
    Run the page and check how the background image appears. Make adjustments to background-size or background-position based on your layout and image dimensions.

 

How to Display a Page Background Image in Oracle APEX

Adding a background image to an APEX page can enhance the user interface and make the application visually appealing. This can be done using CSS, Static Application Files, or inline styles. Below are multiple approaches to accomplish this in Oracle APEX.

 

1. Using CSS to Set a Background Image

The most efficient way to apply a background image is by using CSS.

Steps to Add a Background Image via CSS

  1. Open Oracle APEX Page Designer.

  2. Select the Page Attributes section.

  3. Scroll down to the CSS section and find Inline CSS.

  4. Add the following CSS code:

body {

    background-image: url('&APP_IMAGES.background.jpg');

    background-size: cover;

    background-repeat: no-repeat;

    background-attachment: fixed;

    background-position: center;

}

  1. Click Save and Run the page to see the background image.

Explanation of CSS Properties:

  • background-image: Specifies the image to be used.

  • background-size: cover: Ensures the image covers the full page.

  • background-repeat: no-repeat: Prevents the image from repeating.

  • background-attachment: fixed: Keeps the background image static when scrolling.

  • background-position: center: Centers the image on the page.

 

2. Using a Static Application File for Background Image

If the image is stored in APEX under Static Application Files, reference it dynamically.

Steps to Upload and Use a Static File

  1. Navigate to Shared Components > Static Application Files.

  2. Click Upload File, select the image, and upload it.

  3. Copy the file reference URL from the uploaded file.

  4. Apply the CSS in Page Designer under Inline CSS:

body {

    background-image: url('#APP_FILES#background.jpg');

    background-size: cover;

    background-repeat: no-repeat;

}

APEX will dynamically replace #APP_FILES# with the correct image path.

 

3. Setting Background Image via Page Templates

If the same background image should be applied to all pages, update the Page Template.

Steps to Modify Page Template for Background Image

  1. Open Shared Components.

  2. Click on Themes and choose the theme in use (e.g., Universal Theme).

  3. Select Page Templates.

  4. Edit the Standard Page Template.

  5. Find the <body> tag inside the Template Definition.

  6. Add the following inline CSS before </body>:

<style>

    body {

        background-image: url('&APP_IMAGES.background.jpg');

        background-size: cover;

        background-repeat: no-repeat;

        background-attachment: fixed;

    }

</style>

  1. Save changes and apply them to all pages using the template.


4. Using JavaScript to Dynamically Change Background Image

If the background image should change dynamically based on user actions, use JavaScript.

Steps to Change Background Image Using JavaScript

  1. In Page Designer, navigate to Page Attributes.

  2. Under Execute when Page Loads, add the following JavaScript:

document.body.style.backgroundImage = "url('&APP_IMAGES.dynamic_background.jpg')";

document.body.style.backgroundSize = "cover";

document.body.style.backgroundRepeat = "no-repeat";

  1. This script changes the background when the page loads.

 

5. Changing Background Based on Page Conditions

To change the background based on specific page numbers or conditions:

  1. Go to Page Designer > Execute when Page Loads.

  2. Add the following JavaScript:

if ($v('P1_USER_ROLE') === 'Admin') {

    document.body.style.backgroundImage = "url('&APP_IMAGES.admin_background.jpg')";

} else {

    document.body.style.backgroundImage = "url('&APP_IMAGES.user_background.jpg')";

}

This changes the background dynamically based on user roles.

  

Displaying a background image in Oracle APEX can be done using CSS, Static Application Files, or JavaScript. The best approach depends on the application requirements. Using CSS is ideal for static backgrounds, while JavaScript is useful for dynamic changes based on conditions or user interactions.


EXAMPLE:

Step 1 – Click on the image from Shared Components > Static Application Files




Step 2  - Copy the reference value

A screenshot of a video

AI-generated content may be incorrect.

Your reference should look like this: 

#APP_FILES#JMarketplace/MarketplaceReactive.Complex.jpg


Step 3 – Go to the “Page” level of the page and change the inline CSS

A screenshot of a computer

AI-generated content may be incorrect. A screenshot of a computer program

AI-generated content may be incorrect.

Code: 

#t_PageBody {

background-image: url(#APP_FILES#Marketplace/tplaceReactive.Complex.jpg);

background-size: 100% Auto;

}





Should look like this:


Best Practices for Background Images in Oracle APEX

  • Use Optimized Images to reduce load time; keep images under 500KB if possible.

  • Use high-contrast content to ensure text remains readable over the background.

  • Test on multiple screen sizes (desktop, tablet, mobile) to ensure proper scaling.

  • Use background-size: cover for a full-screen image that adjusts automatically.

  • Avoid clutter—make sure your image supports, not distracts from, the content.

Oracle APEX Documentation Links

 

Conclusion

Displaying a background image in Oracle APEX is a simple way to enhance the visual design of your application. With just a few steps—uploading your image, adding inline CSS, and fine-tuning layout—you can give your APEX page a professional, custom appearance. Just be sure to follow best practices for performance and accessibility to ensure your background looks great and works well for all users.

How Do I Make a Faceted Search Map Page in Oracle APEX

Combining faceted search with a map region in Oracle APEX enables users to filter data visually and spatially at the same time. This design ...