Anki Forums

"add mobile class" not working

For some reason add mobile class in Tools → Manage Note Types → Cards… → Preview → Options is not getting saved. I have css .mobile example class which I want to be used, however, it’s never working on AnkiDroid. When I check “add mobile class” and save, it says “changes saved”, but it’s never working and when I go to Tools → Manage Note Types → Cards… → Preview → Options it is always still unchecked. I went through all steps required before posting here. Could it be just something wrong with my Anki or is it more widely spread bug?

Add mobile class is just a setting to preview how any css added for the mobile class would look.

Basically it adds the mobile class to the preview window. It doesn’t actually change anything in the styling.
Let me know if I was unclear.

2 Likes

aaaa… okay, I thought it’s for enabling it in general. But then, maybe you know what could be the reason why doesn’t it work on AnkiDroid? Only the example class is not shown on mobile
CSS:
.mobile .example {
font-family: arial;
font-size: 15px;
color: white;
}
CARD:
{{FrontSide}}
<hr id=answer>
{{Back}}
<br><br><br>
<div class=example><b>Examples:</b>
{{Example}}<br>
<b>Context: </b>{{Context}}
</div>

That’s odd, this syntax does work for my cards right now.

This seems silly, but could it be because you have the color set to white for the text?

Sorry, only now I had time to look it up. So yeah, the problem seems to lie with the coloring. I use dark mode, which I didn’t test if it’s related, but when the text color is white in the mobile class, it’s not shown on the mobile itself, but if I change the color to let’s say blue, it shows yellow text on the mobile. Seems a bit odd, but I’ve got it working thanks to you. Do you know if I should report this somewhere as a bug or smth like that?

It’s not a bug, AnkiDroid just applies inverted day-mode colors in night-mode, unless you specify colors for night-mode using a specific class name. It’s slightly different from the class used to apply night mode in the desktop. I’ve forgotten what exactly it is though. You can look it up in the docs.
If you remove the color: white; it should default to white text on a black background in night mode. Or you could set the background color to black and use it in day mode.

1 Like