0

我正在编辑使用 HTML 和 CSS的Anki 甲板模板。我想在这里做的是在正面,将日文字符垂直对齐到中间,将提示对齐到底部。我尝试使用 手动分隔所有内容<br>,但它在不同的分辨率窗口中不起作用(而且只是一个肮脏的解决方案

在背面,我想让笔画图总是贴在顶部,带有关键字和助记符的日文字符在中间,其余的在底部。如果我尝试将其与首页分开,<br>我会遇到与首页相同的问题,而且助记符有时是 1 行,但也可以是 5+ 行,因此即使窗口大小始终是,它也必须动态对齐才能工作带有箭头的相同Back 示例。

我已经发现这个问题似乎在某种程度上回答了我的问题,但由于我对 CSS/HTML 几乎一无所知,我不知道如何在我的案例中应用它。如果你能帮助我,我将不胜感激,因为我花了很多时间在这个套牌上,而且它一直让我很烦,我也会分享改进的版本供其他人使用。

这是前面的代码

<div class="front" lang="ja">


<span class="large japanese">{{kanji}}</span>

<br>
<hr>


{{hint:Memory palace}}
背部

<div class="back" lang="ja">
{{strokeDiagram}}<br> <br>
	<hr> 
	<span class="medium"><a href="http://jisho.org/kanji/details/{{kanji}}">{{keyword}}</a></span>
	<br/><br/>
	
<span class="large japanese">{{kanji}}</span>

<br> 
<span class="medium">{{myStory}}</span> 	<br><hr> 
<span class="tiny"> Memory palace: {{Memory palace}}</span>


<span class="tiny"> &nbsp; Frame: {{frameNoV6}} &nbsp; Strokes: {{strokeCount}} &nbsp; &mdash; &nbsp; Jouyou Grade: {{jouYou}} &nbsp; JLPT: {{jlpt}}</span><br/>

<!-- Uncomment for Heisig Story          
<hr>
	<span class="medium">{{heisigStory}}</span>
	{{#heisigComment}}<br/><br/><span class="small">{{heisigComment}}</span>{{/heisigComment}}
-->

<!-- Uncomment for koohi Story
<hr/>
	<span class="medium">{{koohiiStory1}}</span>

-->

<hr/>
 <br> <br>
<!-- Uncomment for On-Yomi and Kun-Yomi
	<span class="small">On-Yomi: <span class="medium japanese">{{onYomi}}</span> &nbsp; Kun-Yomi: <span class="medium japanese">{{kunYomi}}</span></span><br/>
-->
<span class="tiny"><a href="http://kanji.koohii.com/study/kanji/{{kanji}}">Constituents:</a> {{constituent}}</span><br/><br/>
	{{#readingExamples}}<span class="tiny">Examples: <span class="japanese">{{readingExamples}}</span></span>{{/readingExamples}}
</div>
和造型,

div.front, div.back {
	text-align: center;
	font-family: sans-serif;
	font-size: 16px; /* line height is based on this size in Anki for some reason, so start with the smallest size used */

}


span.tiny {font-size: 16px;}
span.small {font-size: 24px;}
span.medium {font-size: 32px;}
span.large {font-size: 96px;}
span.italic {font-style: italic;}

.win .japanese {font-family: "Meiryo", "MS Mincho";}
.mac .japanese {font-family: "Hiragino Mincho Pro";}
.linux .japanese {font-family: "Kochi Mincho";}
.mobile .japanese {font-family: "Motoya L Cedar", "Motoya L Maru", "DroidSansJapanese", "Hiragino Mincho ProN";}

4

1 回答 1

1

正面

div.front,
div.back {
  width: 100%;
  text-align: center;
  font-family: sans-serif;
  font-size: 16px;
  /* line height is based on this size in Anki for some reason, so start with the smallest size used */
}

span.tiny {
  font-size: 16px;
}

span.small {
  font-size: 24px;
}

span.medium {
  font-size: 32px;
}

span.large {
  font-size: 96px;
}

span.italic {
  font-style: italic;
}

.win .japanese {
  font-family: "Meiryo", "MS Mincho";
}

.mac .japanese {
  font-family: "Hiragino Mincho Pro";
}

.linux .japanese {
  font-family: "Kochi Mincho";
}

.mobile .japanese {
  font-family: "Motoya L Cedar", "Motoya L Maru", "DroidSansJapanese", "Hiragino Mincho ProN";
}


/* Positional */

.bottom {
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
}

.center {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  /* I want a better way to do the below! */
  top: 50%;
  transform: translateY(-50%);
}

.top {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}
<div class="front" lang="ja">


  <span class="large japanese center">{{kanji}}</span>

  <hr>


  <span class="bottom">{{hint:Memory palace}}</span>

请注意,<hr>是无样式的。

后退

div.front,
div.back {
  width: 100%;
  text-align: center;
  font-family: sans-serif;
  font-size: 16px;
  /* line height is based on this size in Anki for some reason, so start with the smallest size used */
}

span.tiny {
  font-size: 16px;
}

span.small {
  font-size: 24px;
}

span.medium {
  font-size: 32px;
}

span.large {
  font-size: 96px;
}

span.italic {
  font-style: italic;
}

.win .japanese {
  font-family: "Meiryo", "MS Mincho";
}

.mac .japanese {
  font-family: "Hiragino Mincho Pro";
}

.linux .japanese {
  font-family: "Kochi Mincho";
}

.mobile .japanese {
  font-family: "Motoya L Cedar", "Motoya L Maru", "DroidSansJapanese", "Hiragino Mincho ProN";
}


/* Positional */

.bottom {
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
}

.center {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  /* I want a better way to do the below! */
  top: 50%;
  transform: translateY(-50%);
}

.top {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}
<div class="back" lang="ja">
  <div class="top">{{strokeDiagram}}</div>
  <hr>
  <div class="center"><span class="medium"><a href="http://jisho.org/kanji/details/{{kanji}}">{{keyword}}</a></span>

    <span class="large japanese">{{kanji}}</span>
  </div>

  <div class="bottom">
    <span class="medium">{{myStory}}</span> <br>
    <hr>
    <span class="tiny"> Memory palace: {{Memory palace}}</span>


    <span class="tiny"> &nbsp; Frame: {{frameNoV6}} &nbsp; Strokes: {{strokeCount}} &nbsp; &mdash; &nbsp; Jouyou Grade: {{jouYou}} &nbsp; JLPT: {{jlpt}}</span><br/>

    <!-- Uncomment for Heisig Story          
<hr>
	<span class="medium">{{heisigStory}}</span>
	{{#heisigComment}}<br/><br/><span class="small">{{heisigComment}}</span>{{/heisigComment}}
-->

    <!-- Uncomment for koohi Story
<hr/>
	<span class="medium">{{koohiiStory1}}</span>

-->

    <hr/>
    <br> <br>
    <!-- Uncomment for On-Yomi and Kun-Yomi
	<span class="small">On-Yomi: <span class="medium japanese">{{onYomi}}</span> &nbsp; Kun-Yomi: <span class="medium japanese">{{kunYomi}}</span></span><br/>
-->
    <span class="tiny"><a href="http://kanji.koohii.com/study/kanji/{{kanji}}">Constituents:</a> {{constituent}}</span><br/><br/> {{#readingExamples}}
    <span class="tiny">Examples: <span class="japanese">{{readingExamples}}</span></span>{{/readingExamples}}
  </div>
</div>

这种技术的一个问题是,如果空间不足,它们会相互重叠。

于 2018-04-07T15:52:12.243 回答