Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

teaser styles is not coming fine after adding less file.

Avatar

Level 4

Dear All,

One of my requirement for adding the styles to the teaser is as below. The teaser background color should be blue , as shown in below figure.

1653572_pastedImage_0.png

For this I have created the hometeaser.less file with the below contents.

/* MCK teaser home */

.cmp-teaser--home {   

.cmp-teaser{

        .cmp-teaser__title {

       background-color: #054C70;

        }

        .cmp-teaser__description {

            font-family: @font-family-serif;

        }

    }

}

I have added this hometeaser.less file to my teaser.less file , as shown below

1653573_pastedImage_19.png

Then I have added the policy and style in my editable template , as shown below.

1653574_pastedImage_20.png

But After that also , background color is not coming , as shown below. Can you please help me on this.

1653582_pastedImage_23.png

1 Accepted Solution

Avatar

Correct answer by
Level 10

Are you not able to see the style-brush or the style option "HomeTeaser" itself or otherwise the changes are not visible after applying the style option?

Use developer toolbar to validate the generated DOM structure. It should be something similar to mentioned below as Style System follows the descendant selector convention:

<div class="cmp-teaser--home">  // wrapper class

     <div class="cmp-teaser">   // component specific class

          <div class="cmp-teaser__title">..... </div>

          <div class="cmp-teaser__description">..... </div>

     </div>

</div>

Validate that the generated css has classes ".cmp-teaser--home .cmp-teaser .cmp-teaser__title {...}" and ".cmp-teaser--home .cmp-teaser .cmp-teaser__description {...}"

For displaying background color use:

/* MCK teaser home */

.cmp-teaser--home {  

.cmp-teaser{

     background: color_code_in_HEX;

        .cmp-teaser__title {

       background-color: #054C70;

        }

        .cmp-teaser__description {

            font-family: @font-family-serif;

        }

    }

}

References:

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Are you not able to see the style-brush or the style option "HomeTeaser" itself or otherwise the changes are not visible after applying the style option?

Use developer toolbar to validate the generated DOM structure. It should be something similar to mentioned below as Style System follows the descendant selector convention:

<div class="cmp-teaser--home">  // wrapper class

     <div class="cmp-teaser">   // component specific class

          <div class="cmp-teaser__title">..... </div>

          <div class="cmp-teaser__description">..... </div>

     </div>

</div>

Validate that the generated css has classes ".cmp-teaser--home .cmp-teaser .cmp-teaser__title {...}" and ".cmp-teaser--home .cmp-teaser .cmp-teaser__description {...}"

For displaying background color use:

/* MCK teaser home */

.cmp-teaser--home {  

.cmp-teaser{

     background: color_code_in_HEX;

        .cmp-teaser__title {

       background-color: #054C70;

        }

        .cmp-teaser__description {

            font-family: @font-family-serif;

        }

    }

}

References:

Avatar

Level 10

What is the html of that component looks like once you apply that style ?

Avatar

Level 4

After I put background: color_code_in_HEX; after.cmp-teaser , it is coming fine. .cmp-teaser{     background: color_code_in_HEX;