CSS "glitch"

Hi everyone, I wrote a custom css:

:root .thread {
  --thread-border-color: #F1592A;
	--thread-bg-color: #EEEEEE;

  .thread h1 ,
  .thread .HyperMD-header-1 {
        text-align: right !important;
        line-height: var(--h4-line-height);

        font-size: var(--h4-size) !important;
        font-weight: var(--h4-weight);
        font-family: var(--h4-font);

				border-top: 5px solid var(--thread-border-color) !important;
        border-bottom: 5px solid var(--thread-border-color) !important;
        border-right: 5px solid var(--thread-border-color) !important;
        border-left: 5px solid var(--thread-border-color) !important;

				background-color:var(--thread-bg-color) !important;
				padding:5px !important;

        margin-top: 40px !important;
        margin-bottom: -10px;

.el-h1 ~ .el-p,
.el-h1 ~ .el-ul,
.el-h1 ~ .el-ol,
.el-h1 ~ .el-table,
.el-h1 ~ img
.thread {
    background-color: var(--thread-bg-color) !important;
		padding-top: calc( .1* var(--p-spacing));
		padding-bottom: calc(.1* var(--p-spacing));
		padding-left: 10px;
		padding-right: 10px;
		margin-block-start: calc(-1 * var(--p-spacing));
    margin-block-end: calc(-1 * var(--p-spacing));

		border-bottom: 5px solid var(--thread-border-color) !important;
		border-left:5px solid var(--thread-border-color) !important;
		border-right:5px solid var(--thread-border-color) !important;

But I'm experiencing a glitch when the content of the note become too long, see here:


Does anyone know how to fix this? Thanks

I’ve not seen your video, but this sounds like it could be related to how Obsidian only keep parts of a longer document in memory.

If your CSS targets a part which becomes unloaded due to it not being visible and too far away, then there is suddenly nothing to target and the CSS can glitch…

I don’t think there is any solution to this either, before attaching javascript to your document to forcefully keep it in memory. And that’s not really a good idea or easy to implement in any case.

So, no one knows a easy way to ”fix" this issue?