I am editing the template of an Anki deck, which uses HTML and CSS. What I would like to do here is on the front side, vertically aligning the Japanese character to the middle and the hint to the bottom. I tried manually spacing everything with <br>, but then it doesn't work in different resolution windows (and is just a dirty solution) Front example.
On the back side I would like to make the stroke diagram always snap to the top, the Japanese character with keyword and mnemonic in the middle, and the rest on the bottom. If I tried spacing this with <br> I would get the same problem as on the front page, plus the mnemonic is sometimes 1 line, but can also be 5+ lines so it would have to be aligned dynamically to work even if the window size was always the same Back example with arrows.
I already found this question which seems to somewhat answer my question, but as I know practically nothing about CSS/HTML I don't know how to apply it in my case. If you could help me I would greatly appreciate it as I spend a lot of time with this deck and it keeps annoying me, I would also share the improved version for other people to use.
Here is the code for the front
<div class="front" lang="ja">
<span class="large japanese">{{kanji}}</span>
<br>
<hr>
{{hint:Memory palace}}
back
<div class="back" lang="ja">
{{strokeDiagram}}<br> <br>
<hr>
<span class="medium">{{keyword}}</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"> Frame: {{frameNoV6}} Strokes: {{strokeCount}} — Jouyou Grade: {{jouYou}} 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> Kun-Yomi: <span class="medium japanese">{{kunYomi}}</span></span><br/>
-->
<span class="tiny">Constituents: {{constituent}}</span><br/><br/>
{{#readingExamples}}<span class="tiny">Examples: <span class="japanese">{{readingExamples}}</span></span>{{/readingExamples}}
</div>
and the styling,
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";}
Front
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>
Note that the <hr> is unstyled.
Back
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">{{keyword}}</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"> Frame: {{frameNoV6}} Strokes: {{strokeCount}} — Jouyou Grade: {{jouYou}} 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> Kun-Yomi: <span class="medium japanese">{{kunYomi}}</span></span><br/>
-->
<span class="tiny">Constituents: {{constituent}}</span><br/><br/> {{#readingExamples}}
<span class="tiny">Examples: <span class="japanese">{{readingExamples}}</span></span>{{/readingExamples}}
</div>
</div>
One problem with this technique is that, if there is insufficient space, they will draw over each other.
Related
I have a page which I use margins to place text at different parts of the page as shown below. The A, B, C etc. have been placed there using margin-left in CSS. These however move around depending on the zoom level and resolution of the screen showing them. How can I can place them in the current position so that they won't move around on different screens?
<div>
<div>
<br>
<span class="bigLeft">SECRET.</span>
<span class="bigRight">FORM "F"</span>
</div>
<br>
<br>
<br>
<div>
<span class="biggerCenter">COMBAT REPORT.</span>
</div>
<br>
<br>
<br>
<br>
<br>
<div>
<span class="bigLeft">Sector Serial No.</span>
<span class="bigCenterLettersA">(A)</span>
<span class="bigContentRight"> J.1 </span>
</div>
<br>
<div>
<span class="bigLeft">Serial Number of Order Detailing Flight or Squadron to Patrol</span>
<span class="bigCenterLettersB">(B)</span>
<span class="bigContentRight"> NIL </span>
</div>
<br>
<div>
<span class="bigLeft">Date</span>
<span class="bigCenterLettersC">(C)</span>
<span class="bigContentRight">{{ decodeHTML(report_info.mission_hist_date) }} </span>
</div>
<br>
<div>
<span class="bigLeft">Flight, Squadron</span>
<span class="bigCenterLettersD">(D)</span>
<span class="bigContentRight">{{ flightStatus[report_details.flight] }}, {{ reportUnit.hist_unit_name }} ({{ reportUnit.hist_unit_code }})</span>
</div>
<br>
<div>
<span class="bigLeft">Number of Enemy Aircraft</span>
<span class="bigCenterLettersE">(E)</span>
<span class="bigContentRight"> {{ report_info.enemy_ac_number }} </span>
</div>
<br>
This is the CSS.
<style scoped>
.bigRight {
float: right;
font-size: large;
margin-right: 8%;
}
.bigLeft {
font-size: large;
margin-left: 8%;
}
.bigCenterLettersA {
font-size: large;
margin-left: 48%;
}
.bigCenterLettersB {
font-size: large;
margin-left: 69.1%;
}
.bigCenterLettersC {
font-size: large;
margin-left: 57.3%;
}
.bigCenterLettersD {
font-size: large;
margin-left: 48.5%;
}
.bigCenterLettersE {
font-size: large;
margin-left: 41.8%;
}
.bigCenterLettersF {
font-size: large;
margin-left: 43.8%;
}
.bigCenterPersonnel {
font-size: large;
margin-left: 39.3%;
}
.synopsisText {
text-align: left;
font-size: large;
margin-left: 8%;
margin-right: 8%;
}
.biggerCenter {
font-size: x-large;
text-decoration: underline;
margin-left: 40%;
}
.bigContentRight {
font-size: large;
position: absolute;
margin-left: 2%;
}
.bigContentLeft {
font-size: large;
position: absolute;
margin-left: 1%;
}
.bigContentCenter{
font-size: large;
position: absolute;
margin-left: 19%;
}
</style>
If you don't change the height and width of an element you can set them to a fixed position in the page with
.bigLeft {
position: absolute;
top: 100px;
left: 8vw;
}
That being said this isn't advised because it can become a huge mess.
Also another side note that this would require a fixed width page using the second method as well.
Another possibility would be to make the browser render in a set width no matter screen width.
<meta name="viewport" content="width=1920px">
Though again this isn't the nicest thing to do.
Personally i'd go with setting the width of the "page" to your desired width using min-width and max-width and then using margin-left: 100px etc to position your elements.
Using position: relative could also do the trick here.
I have the following web page:
http://designsystem.foamfactory.io/current/components/preview/main.html
It's basically a set of text, along with a couple of SVG images. In order to get the effect that I want (the hex bolts should be overlaid in a specific position on the text), I use absolute positioning within a relatively positioned container.
The actual HTML code and CSS are fairly simple, and outlined in this codepen:
https://codepen.io/jwir3/pen/ZEzRKyz
The associated HTML is:
<div class="lockup">
<img class="lockup-logo logo-medium" src="http://designsystem.foamfactory.io/current/dist/assets/logos/Logo.svg" />
<div class="textmark textmark-medium">
<div id="hex-bolt-f-top">
<img src="http://designsystem.foamfactory.io/current/dist/assets/misc/Hex%20Bolt.svg" />
</div>
<div id="hex-bolt-f-bottom">
<img src="http://designsystem.foamfactory.io/current/dist/assets/misc/Hex%20Bolt.svg" />
</div>
<div id="hex-bolt-y-middle">
<img src="http://designsystem.foamfactory.io/current/dist/assets/misc/Hex%20Bolt.svg" />
</div>
<div id="hex-bolt-y-bottom">
<img src="http://designsystem.foamfactory.io/current/dist/assets/misc/Hex%20Bolt.svg" />
</div>
<div class="textmark-text">Foamfactor<span class="last-letter">y</span></div>
</div>
<div class="empty"></div>
</div>
and CSS:
.lockup {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
-ms-flex-pack: start;
justify-content: flex-start;
}
.lockup .empty {
-ms-flex-positive: 4;
flex-grow: 4;
}
.lockup-logo {
display: inline;
}
.textmark {
display: inline-block;
box-sizing: border-box;
position: relative;
padding: 0;
-ms-flex: 1 1 0px;
flex: 1 1 0;
margin-left: .2em;
}
.textmark .textmark-text {
display: block;
color: black !important;
box-sizing: border-box;
font-family: "Staatliches";
line-height: 1.0;
letter-spacing: -.04em;
}
.textmark.textmark-large {
font-size: 200pt;
}
.textmark.textmark-large .textmark-text::first-letter,
.textmark.textmark-large .textmark-text .last-letter {
font-size: 300pt;
}
.textmark.textmark-large .textmark-text .last-letter {
margin-left: -.04em;
}
.textmark.textmark-medium {
font-size: 80pt;
}
.textmark.textmark-medium .textmark-text::first-letter,
.textmark.textmark-medium .textmark-text .last-letter {
font-size: 120pt;
}
.textmark.textmark-medium .textmark-text .last-letter {
margin-left: -.04em;
}
.textmark.textmark-small {
font-size: 40pt;
}
.textmark.textmark-small .textmark-text::first-letter,
.textmark.textmark-small .textmark-text .last-letter {
font-size: 60pt;
}
.textmark.textmark-small .textmark-text .last-letter {
margin-left: -.04em;
}
.textmark.textmark-tiny {
font-size: 24pt;
}
.textmark.textmark-tiny .textmark-text::first-letter,
.textmark.textmark-tiny .textmark-text .last-letter {
font-size: 36pt;
}
.textmark.textmark-tiny .textmark-text .last-letter {
margin-left: -.04em;
}
.textmark #hex-bolt-f-top img,
.textmark #hex-bolt-f-bottom img,
.textmark #hex-bolt-y-bottom img,
.textmark #hex-bolt-y-middle img {
width: .08em;
}
.textmark #hex-bolt-f-top {
position: absolute;
top: -.6em;
left: .1em;
}
.textmark #hex-bolt-f-bottom {
position: absolute;
bottom: .1em;
left: .1em;
}
.textmark #hex-bolt-y-bottom {
position: absolute;
bottom: .1em;
right: .2282em;
}
.textmark #hex-bolt-y-middle {
position: absolute;
top: -.1em;
right: .2282em;
}
In Chrome, this always looks how I would expect. In Firefox (I'm using Nightly, but I have tried it on the latest release as well), however, the hex bolts on the far right of the div (the "Y") are too far to the right. Even stranger, most of the time it looks fine in Firefox, too, but when I inspect it using dev tools, it changes the width of the box or something, and it gets screwed up until I shift-refresh (a simple refresh won't fix the issue).
I'm fairly certain that the problem lies with the fact that the outermost div for this entire text/logo combination is a flexible box. The reason I have it that way is to center it on the page. Perhaps there is another way to achieve the results I want without this?
More to the point, I'm unclear on why the behavior is different between the two browsers. Have I hit on an area where the specification isn't well defined?
this solves the issue but you need to correct the first letter
.textmark .textmark-text {
display: inline;
}
I think the easiest way would be to center it with this:
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
That way you only have something like:
<body class="frontmatter index">
<div class="centered">
<div>
<div class="lockup">
<img class="lockup-logo logo-medium" src="../../dist/assets/logos/Logo.svg">
<div class="textmark textmark-medium">
<div id="hex-bolt-f-top">
<img src="../../dist/assets/misc/Hex Bolt.svg">
</div>
<div id="hex-bolt-f-bottom">
<img src="../../dist/assets/misc/Hex Bolt.svg">
</div>
<div id="hex-bolt-y-middle">
<img src="../../dist/assets/misc/Hex Bolt.svg">
</div>
<div id="hex-bolt-y-bottom">
<img src="../../dist/assets/misc/Hex Bolt.svg">
</div>
<div class="textmark-text">Foamfactor<span class="last-letter">y</span></div>
</div>
<div class="empty"></div>
</div>
</div>
<h2>An elegant brewery management system for a more civilized age</h2>
</div>
....
</body>
Flexbox might be a little overkill for this in my opinion.
I think you need check this website:
https://validator.w3.org
and scan your website there that web will tell you where to fix your web struct as I check there is many attribute and tag are missing from your web. you may think this is not the problem that cause your website struct error. So please go to that website and fix what is the error left in your web structure.
How do I have a bigger font size for only a single character in a sentence?
For a example: All characters except - in "Click - sign" should be font size 13. And only - should be font size 55. The sentence should look normal.
See Fiddle. The - sign is higher than the rest of the text.
<div class="aa">
Click <span Style="font-size:30px; line-height:45px;">-</span> sign
</div>
aa {
font-size: 13px;
}
EDIT:
Here you can use position: relative; for hyphen:
span {font-size:30px; position: relative; top: 3px;}
https://jsfiddle.net/fLvtjwcw/1/
use this css
* {
margin: 0;
padding: 0;
}
p {
font-size: 13px;
}
p span.hlt_txt{
font-size: 55px;
line-height: 0;
vertical-align: top;
}
HTML
<p class="aa">
Click <span class="hlt_txt">-</span> sign
</p>
How it should be: http://prntscr.com/59nrxz
How it is: http://prntscr.com/59nsfg
My HTML:
<div class="col-md-6 logo" id="header-logo">
<a href="{{ path('static_page', {template:'home'}) }}" title="Return Home">
<img alt="logo" src="static/img/Risne-Logo.png"></img>
<span class="logo_left">RISNE</span>
<span class="logo_right">STARS</span>
</a>
</div>
My CSS:
.logo_left, .logo_right {
font-family: "Droid Sans";
font-size: 34px;
top: -20px;
}
.logo_right {
color: #FECD0F;
}
.logo_left {
color: #234371;
}
I don't care about font or anything, i just need to get the text to move to the right position.
Depending on what you want, a simple position: relative could do the trick.
.logo{
position: relative;
top: -20px; /* This will move it 20px up */
left: 20px; /* This will move it 20px to the right */
}
That'a assuming that you put both of your span's in a div (or heading) that has a class of logo.
Try this it might do the trick :
.logo_left, .logo_right{
vertical-align : top;
margin-left : 10px;
}
1) I was wondering how I can have this text all in one block aligned centerally in the page (both vertically and horizontally).
2) I also want each line of text flush with the other lines of text. Any ideas?
Demo
HTML
<div class="row">
<div class="panel">
<div class="large-12 columns" id="date"><span>5TH MAY 2014</span>
</div>
<div class="row">
<div class="large-12 columns" id="title"><span>HIGHGATE MARKET & FAIR</span>
</div>
<div class="row">
<div class="large-12 columns" id="desc"><span>ARTS, CRAFTS, COLLECTABLES AND FINE FOODS</span>
</div>
<div class="row">
<div class="large-12 columns" id="address"><span>Lauderdale House Waterlow Park Highgate Hill Highgate N6 5HG</span>
</div>
</div>
</div>
CSS
#date {
font-size: 114.42px;
}
#title {
font-size: 61.88px;
}
#desc {
font-size: 33.27px;
}
#address {
font-size: 21.68px;
}
.panel {
background-color: #202020;
border-style: none;
}
#font-face {
font-family:'adamregular';
src: url('adam-webfont.eot');
src: url('adam-webfont.eot?#iefix') format('embedded-opentype'), url('adam-webfont.woff') format('woff'), url('adam-webfont.ttf') format('truetype'), url('adam-webfont.svg#adamregular') format('svg');
font-weight: normal;
font-style: normal;
}
body {
font-family:'adam';
color: #B9B8B9;
background-color: #202020;
text-align: center;
position: absolute;
top: 0 bottom: 0;
left: 0;
right: 0;
}
Example fiddle: http://jsfiddle.net/T2T69/1/
with the markup you provided you can remove the absolute position from body and add this style
html, body {
height: 100%;
margin: 0;
padding: 0;
}
body {
display: table;
width: 100%;
}
body > .row {
display: table-cell;
vertical-align: middle;
text-align: center;
}
Example screenshot (on firefox 27)
As a side note, I would suggest to use a cleaner markup instead of nested div, something like
<section>
<time datetime="2014-05-05">5TH MAY 2014</time>
<h1>HIGHGATE MARKET & FAIR <span>ARTS, CRAFTS, ..., FOODS</span></h1>
<p>Lauderdale House Waterlow Park Highgate Hill Highgate N6 5HG</p>
</section>