Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I put a style into a user macro ?

Hello,

 

I want to make a user macro that write numbered headings in the page where it is placed. I tried to do that but the style is overwritten by the global stylesheet. Do you have an idea to help me ?

 

#content.page.view {
/* Set "title1" to 0 */
counter-reset: title1;
}

#content.page.view h1 {
/* Set "title2" to 0 */
counter-reset: title2;
}
#content.page.view h1:before {
/* Increment "title1" by 1 */
counter-increment: title1;
content: counter(title1) ". ";
}

#content.page.view h2 {
/* Set "title3" to 0 */
counter-reset: title3;
}
#content.page.view h2:before {
/* Increment "title2" by 1 */
counter-increment: title2;
content: counter(title1) "." counter(title2) ". ";
}

#content.page.view h3 {
/* Set "title4" to 0 */
counter-reset: title4;
}
#content.page.view h3:before {
/* Increment "title3" by 1 */
counter-increment: title3;
content: counter(title1) "." counter(title2) "." counter(title3) ". ";
}

#content.page.view h4 {
/* Set "title5" to 0 */
counter-reset: title5;
}
#content.page.view h4:before {
/* Increment "title4" by 1 */
counter-increment: title4;
content: counter(title1) "." counter(title2) "." counter(title3) "." counter(title4) ". ";
}

#content.page.view h5 {
/* Set "title6" to 0 */
counter-reset: title6;
}
#content.page.view h5:before {
/* Increment "title5" by 1 */
counter-increment: title5;
content: counter(title1) "." counter(title2) "." counter(title3) "." counter(title4) "." counter(title5) ". ";
}

#content.page.view h6:before {
/* Increment "title6" by 1 */
counter-increment: title6;
content: counter(title1) "." counter(title2) "." counter(title3) "." counter(title4) "." counter(title5) "." counter(title6) ". ";
}

2 answers

1 vote
Bill Bailey Community Leader Sep 21, 2021

The trick here is to wrap the content of your macro in a classed div tag, then adjust your CSS rules accordningly.

<div class="myclass">
$body
</div>
1 vote
Brant Schroeder Community Leader Sep 20, 2021

@Florent R_ 

You should be able to do it if you use some additional hierarchy in the CSS.  

Thanks
Brant

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

43,730 views 33 136
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you