question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mermaid resets some of the page CSS styles

See original GitHub issue
<head>
  <!-- ... -->
  <link rel="stylesheet" href="/assets/css/all.css">
  <link rel="stylesheet" href="https://cdn.rawgit.com/knsv/mermaid/7.0.0/dist/mermaid.css">
  <script src="https://cdn.rawgit.com/knsv/mermaid/7.0.0/dist/mermaid.min.js"></script>
  <script>mermaid.initialize({startOnLoad: true;});</script>
</head>
<body>
<div class="mermaid">
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
</div>
<h1>Foo</h1>

The page is deployed on a local Jekyll server. The h1 styling set by all.css is displayed correctly up until the point when the graph is rendered. The behavior is hard to reproduce: I was not able to reproduce it outside of my own blog served locally via Jekyll. Given this, can you please suggest a quick fix that would guarantee that mermaid will have absolutely no effect beyond a tag I have specified? I do not want it to influence anything else but the contents of the tag I am trying to render.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
itamarstcommented, Mar 1, 2017

Passing in option cloneCssStyles: false in the configure object passed to mermaid.initialize() fixes a similar problem for me:

<script>mermaid.initialize({
       startOnLoad: true,
       cloneCssStyles: false
     });
</script>
1reaction
tylerlongcommented, Mar 17, 2018

The issue has been fixed. Now all mermaid CSS are scoped within its own ID so it won’t pollute global CSS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mermaid resets some of the page CSS styles #482 - GitHub
The page is deployed on a local Jekyll server. The h1 styling set by all.css is displayed correctly up until the point when...
Read more >
CSS not running in mermaid JS, - Stack Overflow
I am just learning mermaid.js and this is some simple code. I declare a cssClass in the div to add do some styles,...
Read more >
CSS Tools: Reset CSS - meyerweb.com
The goal of a reset stylesheet is to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings,...
Read more >
Markdown syntax for wikis - Azure DevOps - Microsoft Learn
Learn how to share information and add tables & mathematical notation using Markdown within wikis.
Read more >
Making Mermaid Diagrams in Markdown - CSS-Tricks
Mermaid diagrams pair well with Jamstack and static site generators, which continue ... theme changes the styling of the rendered diagrams.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found