Hello everyone,
I know that this topic has been treated multiple times here and there but I have tried all my best with many headaches without success so here I am.
Basically, I’ve managed to build this beautiful type-in template and I’d like 2 more things to make it perfect:
- Add a hint field in very tiny fonts at the bottom of the rectangle
- Make that hint only showing when pressing H key on the Front, BUT always showing up when revealing the Back (because I always want to see the hints with answers).
I know it might be simple but with my limited knowledge of HTML and CSS I couldn’t find a way to make it. I already managed to create the rectangle that will have a fixed dimension whatever the windows size^^
So here is my code if you want to have a look.
Extra is my hint field btw
Many thanks for your help!
Front
<body class="card">
<div id="qa">
<!-- Start of template -->
<div class="kard">
<div class="textbox">{{Front}}</div>
<hr id="answer">
<div class="textbox">{{type:Back}}</div>
</div>
<!-- End of template -->
</div>
</body>
</div>
<script>
(() => {
/**
* Type-in-the-answer live feedback for Anki (vague variant)
* @author Matthias Metelka | @kleinerpirat
*/
const input = document.getElementById("typeans");
const answer = "{{Back}}";
if (input) {
input.addEventListener("input", () => {
input.classList.add("typed");
input.classList.toggle(
"goodsofar",
input.value == answer.substring(0, input.value.length)
);
input.classList.toggle(
"correct",
input.value == answer
);
});
}
})();
</script>
<script>
document.getElementById("typeans").style.fontSize = "45px";
</script>
Back
<div class="backtemplate">{{FrontSide}}
</div>
<br>
<div class="note">
<div id="extra" class="front extra">
<div class="exlink">
{{#Front}}
<script>
q = document.getElementById('Target');
q.innerHTML = q.innerHTML.replace(/({{Front}})/g, '<span class="expression">\$1</span>');
</script>
{{/Front}}
<span id="Target"> {{edit:Extra}}</span>
<div class="exdef">
<div class="exsyn">
</div>
CSS
<div style="display:flex">
<img src="" style="display:block !important; margin:auto">
</div>
/* center #qa inside .card (the body) */
.card {
font-size: 1.2rem;
text-align: center;
background-color: #8ab0ae;
--text-fg: #575e6f;
--text-bg: rgba(255, 255, 255, .5);
--kard-bg: #fed6bc;
}
/* make #qa (child of .card) centerable */
/* and left-aligned */
#qa {
min-width: 40%;
display: inline-block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
box-sizing: border-box;
display: inline-block;
}
.kard {
padding: 2rem 10rem;
background: #3D3847;
box-shadow: rgba(0, 0, 0, 0.30) 0px 0px 25px 4px;
border-radius: 15px;
}
.textbox {
display: inline-block;
text-align: left;
color: vwhit;0.1rem 0.1rem 0 var(--text-bg);
height: 100px;
}
hr#answer {
margin-top: -3rem;
margin-bottom: 1rem;
border: 0;
height: ;
border-top: thin solid rgba(, 0, 0, 0.);
border-bottom: thin solid rgba(255, 255, 255, 0.3);
}
/* for landscape orientation */
/* only use part of the available width */
@media (min-width: 500px) {
#qa {
min-width: 500px;
max-width: 600px;
font-family: arial;
*/
}
}
@media (min-width: 1366px) {
#qa {
min-width: 600px;
max-width: 600px;
}
}
...................
.card {
font-size: 45px;
color: black;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 150px;
height: 200px;
}
input[type=text]:focus {
}
input[type=text]{
background-color: rgba(0,0,0,0);
text-align: center;
cursor: text;
border-radius: 5px;
border-style: solid;
border-width: px;
margin-top: 3.px;
font-size: 50px;
}
input#typeans {
font-family: "Arial;
font-weight: bold;
font-size:8px;
}
.card, input {
font-family: "Arial", "Comic Sans", cursive !important;
font-size: 45px !important;
text-align: center;
color: #FAEBD7;
background-color: crimson;
}
#typeans{
font-family: "Arial";
font-weight: bold;
font-size: 45px
text-align: center
}
.extra {
</div>
font-family: "Ubuntu", Helvetica, Arial;
font-size: 30px;
line-height: 1.5;
word-break: keep-all;
text-align: center;
color: #FFE4C4;
}