Type Answer: Ignore an EMPTY 'Type Answer Box'?

I absolutely want the option to type in the answer (to practice spelling), but I only use it in about 5% of reps; plus, I never know in advance whether I’ll need to type the answer or not (so I can’t use different Note Types).

It slightly annoys me that if I don’t type the answer (ie 95% of the time), the displayed answer on the card is shifted down a bit …

Would there be a way to fix this? Anki would have to know that if the ‘Type Answer Box’ stays empty, then ignore type:Answer.

Front Template:

{{#Question}}
<div style='text-align:center;'>   {{Question}}   </div> <br>
{{/Question}}

{{#Answer}}
<div style='text-align:center;'> {{type:Answer}} </div> <br>
{{/Answer}}

Back Template:

{{#Question}}
<div style='text-align:center;'>   {{Question}}   </div>
{{/Question}} <br>

{{#Answer}}
<div style='text-align:center;'> {{type:Answer}} </div> <br>
{{/Answer}}

You can make use of the fact that the <br> will be the first child of the #typeans container if the input is left empty. Add the following CSS rule to your Styling section:

#typeans br:first-child,
#typeans br:first-child + #typearrow  {
  display: none;
}
2 Likes

Thanks; halfway there … :wink:

The answer now takes the place of the arrow, which is still one ‘floor’ below where the Type Answer Box was; i.e. the position that a correctly typed answer has.

I’m fine doing my reps as things are; but it would be cool if vanilla Anki itself would not reserve any space for a completely empty Type Answer Box, as this does not seem to make sense (or maybe I’m overlooking something?) …

Anyway, thanks again :smiley:

Ah, I missed another <br> after that arrow because I was testing with a different template.

Add this third selector to the CSS rule:

#typeans br:first-child,
#typeans br:first-child + #typearrow,
#typeans br:first-child + #typearrow + br  {
  display: none;
}

Also, you can clean up your Front & Back template a bit like this:

{{#Question}}
{{#Answer}}
  <div>{{Question}}</div>
  <br>
  <div>{{type:Answer}}</div>
{{/Answer}}
{{/Question}}
3 Likes

Gepriesen sei der kleine Pirat; möge das Schicksal ihm allzeit gewogen bleiben … :wink:

Thanks; everything looks perfect now … :smiley: :smiley:

As for cleaning up, I’m still experimenting a lot with the layout; all sorts of nesting would make it more complicated to move fields around … thanks anyway for that tip !

1 Like