CSS for Admonition Extension

Feel free to flame me if I’m too far off track.

I’m using Python-Markdown - admonition extension but there is no CSS included as part of this extension.

Would someone give me some guidance how to style the following code. This includes the code and where to put it.

!!! danger highlight blink "Don't try this at home"
    ...

will render:

<div class="admonition danger highlight blink">
<p class="admonition-title">Don't try this at home</p>
<p>...</p>
</div>

I’m looking for something similar to what is rendered in MkDocs:

image

Danger: would suffice instead of the lightning icon (I wasn’t aware css could insert text) but I’d like a different style for the admonition-title, and a different one again for the paragraph.

You should look at the CSS for MkDocs.

Thank you. As a noob I’m pretty happy with the start:

  1. I still don’t understand how to get the admonition-title (danger) in the output from the stylesheet.
  2. Given the html is autogenerated there must be some way of getting it to use stylesheet.css.

Output:

image

The CSS code in my system is incredibly complicated but by looking at https://github.com/mkdocs/mkdocs/blob/master/mkdocs/themes/mkdocs/css/base.css I saved the following code to a file following a guide:

stylesheet.css

.admonition {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    text-align: left;
}

.admonition.note { /* csslint allow: adjoining-classes */
    color: #3a87ad;
    background-color: #d9edf7;
    border-color: #bce8f1;
}

.admonition.warning { /* csslint allow: adjoining-classes */
    color: #c09853;
    background-color: #fcf8e3;
    border-color: #fbeed5;
}

.admonition.danger { /* csslint allow: adjoining-classes */
    color: #b94a48;
    background-color: #f2dede;
    border-color: #eed3d7;
}

.admonition-title {
    font-weight: bold;
    text-align: left;
}

I’ve narrowed it down to the link and article elements:

<!DOCTYPE html>
<html lang="en" class="no-js">

<head>
    <link rel="stylesheet" href="assets/stylesheets/main.6e35a1a6.min.css" />
</head>

<body>
    <article class="md-content__inner md-typeset">

        <div class="admonition danger highlight blink">
        <p class="admonition-title">Don't try this at home</p>
        <p>...</p>
        </div>
        <p>Following paragraph.</p>

    </article>
</body>

</html>

There is about 4000 lines of CSS but I can see in developer tools there is aonly about 100 lines used. How do I narrow it down to the key bits?

Well it’s pretty unremarkable. Basically, there is a placeholder for supported admonition icons.

Probably much more difficult with labels.