gpt4 book ai didi

html - Anki CSS/HTML 垂直对齐底部/中心/顶部

转载 作者:太空宇宙 更新时间:2023-11-04 07:27:53 29 4
gpt4 key购买 nike

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

在背面,我想让笔划图始终对齐到顶部,带有关键字和助记符的日语字符位于中间,其余位于底部。如果我尝试用 <br> 间隔它我会遇到与首页相同的问题,而且助记符有时是 1 行,但也可能是 5 行以上,因此即使窗口大小始终相同,它也必须动态对齐才能工作 Back example with arrows .

我已经找到了this这个问题似乎在某种程度上回答了我的问题,但由于我对 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";}

最佳答案

正面

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>

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

关于html - Anki CSS/HTML 垂直对齐底部/中心/顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49708942/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com