How to format an inline code in Confluence?

后端 未结 15 585
夕颜
夕颜 2020-12-22 17:57

How can I format an inline code in Confluence like this? I mean, not a separate code block, but just inline classname, for example.

15条回答
  •  时光取名叫无心
    2020-12-22 18:43

    By default Confluence renders monospaced text with transparent background. You can edit global CSS to add grey color. From Confluence manual:

    1. Choose the cog icon at top right of the screen, then choose Confluence Admin.
    2. Choose Stylesheet.
    3. Choose Edit.
    4. Paste your custom CSS into the text field.
    5. Choose Save.

    Custom CSS for displaying grey background in monospaced blocks:

    code {
        padding: 1px 5px 1px 5px; 
        font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
        background-color: #eeeeee;
    }
    

    If you're using Confluence OnDemand (cloud):

    1. Click the cog/gear in the bottom of the sidebar on the left
    2. Select Look and Feel
    3. Click the Sidebar, Header and Footer tab
    4. Paste your custom CSS into the Header field
    5. Wrap the code in a {style} block
    6. Save

    Paste the following:

    {style}
    code {
        padding: 1px 5px 1px 5px; 
        font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
        background-color: #eeeeee;
    }
    {style}
    

    After that you'll get nice and tidy stackoverflow-stylish inline code spans just by writing {{sometext}}.

提交回复
热议问题