How to add class to the body when user is on particular page? In my case this is "error" page (404/403 etc.)
Archive
I should add that I want to do it for .twig page, not .md page.
Solved it! In case someone is looking for same solution:
In my base.html.twig I have:
TWIG
{% block body %}
<body>
{% endblock %}
In my error page error.html.twig I defined a class that will be added to the body everytime browser display error page:
TWIG
{% block body %}
<body class="error-page">
{% endblock %}
And then I target in CSS:
TXT
body.error-page {
// your css
}
Log in to reply.
Suggested topics
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 0 | 1370 | 9 years ago | ||
| 2 | 943 | 9 years ago | ||
| 2 | 4069 | 9 years ago | ||
| 1 | 2960 | 9 years ago | ||
| 3 | 1127 | 9 years ago |