Certain element SOMETIMES centered

Hi! I’m really lost about this.
I’m using Anki to learn Japanese words, and am having a really curious problem.
When a word has ONE pitch graph, it looks normal.

BUT, if a word has TWO pitch graphs, they get alligned to the LEFT.

I mine these cards automatically with a program called Yomitan. I don’t know much about how it works.

So… what gives? How can I make it so the graph is always centered?

Fields I have in my cards:

Card template:


FRONT TEMPLATE

<div id='expression-field'>{{Word}}</div>
<div id='hint-field'>{{Hint}}</div>

<!--If the word is hiragana/katakana only, display the sentence in the hint field.-->
<script>
if ("{{Word}}" === "{{Reading}}") {
    if (document.getElementById('hint-field').childNodes.length === 0) {
        document.getElementById('hint-field').innerHTML  = "{{Sentence}}"
    }
}
</script>


----------------------------------------------------------------------------------------------

BACK TEMPLATE

{{FrontSide}}



<div id="box-definition">
<div id="reading-field">
<div id="accent-graph">{{Graph}}</div>
{{Reading}}
</div>
<div id="glossary-field">{{Glossary}}</div>
<div class="main_image">{{Picture}}</div>
</div>

<div id="sentence-field">{{Sentence}}</div>

<p>{{Audio}}{{SentenceAudio}}</p>

<script>
// Remove 'No pitch accent data' text
if (document.getElementById('accent-graph').innerHTML === "No pitch accent data") {
    document.getElementById('accent-graph').style.visibility = "hidden"
}
</script>


------------------------------------------------------------------------------------------------

STYLING

.card {
    font-family: "MS UI Gothic", "Noto Sans CJK JP", "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Osaka, メイリオ, Meiryo, "MS Pゴシック", "MS PGothic", "MS ゴシック", "MS Gothic", TakaoPGothic, sans-serif;
    font-size: calc(1.5em + 3vmax);
    text-align: center;
    color: black;
    background-color: #e8e8df;
    margin-left: auto;
    margin-right: auto;
}



/*Adjust cards to screen size*/
@media screen and (orientation: portrait) {
    .card {
        max-width: 100%;
        font-size: calc(1.5em + 3vmax);
    }
}

@media screen and (orientation: portrait) and (min-height: 1000px) {
    .card {
        max-width: 100%;
        font-size: calc(2em + 5vmax);
    }
}

@media screen and (orientation: landscape) {
    .card {
        max-width: 80%;
    }
}

@media only screen and (orientation: landscape) and (min-width: 1200px) {
    .card {
        max-width: 70%;
    }
}

@media only screen and (orientation: landscape) and (min-width: 2000px) {
    .card {
        max-width: 50%;
        font-size: calc(1em + 3vmax);
    }
}


/*Basic spacing and font size options*/

#expression-field {
    margin-bottom: -0.2rem;
}

#hint-field {
    font-size: 40%;
}

#reading-field {
    font-size: 60%;
}

#glossary-field {
    text-align: center;
    font-size: 30%;
}
}

#sentence-field {
    font-size: 50%;
}

#accent-graph {
    font-size: 50%;
    transform: scaleX(1.3);
}

/*Restrict size of screenshots.*/

img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: 600px;
    max-height: 300px;

}



/*Create border*/
#box-definition {
    border: 1px solid gray;
    border-radius: 20px;
    width: fit-content;
    padding: 5px;
    margin: 0px;
}


#box-definition {
  width: max-content;
  margin: 0 auto;
  border: 1px solid gray;
  border-radius: 20px;
  width: fit-content;
}

An explanation of how this works and what’s going on would be nice, but a simple solution is ok too!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.