Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9252191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:52:59+00:00 2026-06-18T10:52:59+00:00

When for example, we would normally add background images into a stylesheet via a

  • 0

When for example, we would normally add background images into a stylesheet via a class, is it possible in cq for an author to specify an image, and cq itself to amend the CSS to add the class and background image specification.
I guess the other way is for the sling resource to add an inline stylesheet. What’s the best method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:53:00+00:00Added an answer on June 18, 2026 at 10:53 am

    I’ve done something similar in modifying components in CRX(DE) using an inline stylesheet so that their dialogue window has additional fields for users to enter. I added to the image component a field for having a target image selected from the DAM for target when clicked.

    You could do something along the lines of this:

    Component properties

    /yoursite/components/content/-yourcomponent-/dialog/items/bgImage (your component tree may vary slightly)
    
    fieldLabel : String = Image to Link to
    jcr:primaryType : Name = cq:Widget
    name : String = ./bgImage
    xtype : String = pathfield
    

    Add the following to /yoursite/components/content/-yourcomponent-/yourcomponent.jsp

    <%
    String bgImage = properties.get("bgImage", "");
    String cssStyle = "";
    if (bgImage != null) {
      cssStyle = "background:url(" + bgImage + ") no-repeat;";
    }
    %>
    
    <div style="<%= cssStyle %>">
      // Other output here
    </div>
    

    This is a very rough draft, but you should get the idea.

    Update: If you wish to add CSS classes externally, and reference them in code. However, you’d still have to append a user-selected image as an inline, or internally.

    • In CRX(DE), expand /etc/designs/-yoursite-/styles.css/files in your development/author instance
    • Add a new CSS file accordingly, or append your code to an existing file
    • The system will merge all CSS files into one huge styles.css file
    • styles.css is cached by the system, so changes may not occur immediately based on application settings.

    <div class="imageDiv" style="<%= cssStyle %>"> </div>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The simplest example would be the built in class keyValuePair(of T,U). I would like
I would like to change: http://example.com/index.php?p=blog&pid=2&lid=1&l=en into just http:// example.com/en/blog.html or just http:// example.com/blog.html
Where would you put global constants in a C++ application? For example would you
I'm looking for a good and useful code example that would be nice, short
I couldn't figure out that from SASS documentation. For example I would like to
Is there anything in boost libraries like binary? For example I would like to
Given the string Wibble eq wobble myhost.example.com I would like to be able to
This would be an example of database table: PHP script should limit query result
I would like to see how this example of existing code would be able
For example var string = 'width=300 height=650' i would like to update height in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.