Misalignment of <div> for UTF-8 Japanese chars - html

.element-label {
display: block;
float: left;
width: 260px;
padding-left: .5em;
background: #f0f0f0;
color: #A00000;
font-size: 9pt;
}
.element-value {
display: block;
float: left;
margin-left: 1em;
font-weight: bolder;
white-space: nowrap;
font-size: 9pt;
}
<div id="field1">
<span class="element-label">Label 1 </span>
<span class="element-value">テスト </span>
</div>
<br />
<div id="field2">
<span class="element-label">Label 2 </span>
<span class="element-value">testing value</span>
</div>
In MS IE:
However, in Chrome or MS Edge:
the html looks like:
The layout in IE is what I expect/want.
However, when I change to the Japanese chars to other language chars (English, Chinese, Korean, etc.).
They all look right.
How can I format the Japanese chars correctly in this case
Why Japanese chars are so special in this case in different browsers provided that they are all UTF-8 encoded?

Why Japanese chars are so special in this case in different browsers
provided that they are all UTF-8 encoded?
They are special because they use different font and therefore are taller than Latin characters. You can see the same result if you use Latin text, but increase the font-size for that specific value span.
However the main problem is that your wrapper div elements are basically non-existent and not forcing child elements to be in rows and therefore each element is trying to be next to its sibling. If you removed the br element you would see that there is only one row.
A better solution is to use css to order your elements into rows and remove the br completely. Simple way to do that is to use flex on your wrapper elements. Also you should fix the height of rows to get a more consistent appearance (I added line-height to counter that).
.element-label {
display: block;
float: left;
width: 260px;
padding-left: .5em;
background: #f0f0f0;
color: #A00000;
font-size: 9pt;
}
.element-value {
display: block;
float: left;
margin-left: 1em;
font-weight: bolder;
white-space: nowrap;
font-size: 9pt;
}
.row {
display: flex;
line-height: 9pt;
margin-bottom: .3em;
}
<div class="row" id="field1">
<span class="element-label">Label 1 </span>
<span class="element-value">テスト </span>
</div>
<div class="row" id="field2">
<span class="element-label">Label 2 </span>
<span class="element-value">testing value</span>
</div>

Related

How to make text dynamically break or going to next line?

I have a design like this:
You see the middle text,when it's too big it spoils my design.
here you can see
I want after a certain characters it will go down from where location started and continue.I am a noob. Please Help me.
My HTML:
<div class="title-body">
<h4 id="title"></h4>
<div class="info">
<span class="company"><i data-feather="briefcase"></i><span id="company_name"></span></span>
<span class="office-location"><a href="#"><i data-feather="map-pin"></i><span id="company_location"
style="word-break: break-all;width:14px;"></span></a></span>
<span class="job-type full-time"><a href="#"><i data-feather="clock"></i><span
id="employment_status"></span></a></span>
</div>
</div>
CSS
element.style {
word-break: break-all;
width: 14px;
}
.job-title-and-info .title .title-body .info span {
font-size: 1.4rem;
font-weight: 400;
font-family: "Roboto", sans-serif;
margin-right: 15px;
color: #6f7484;
Update your CSS to have a max-width property.
Based off what you have, you could add this block of code to your CSS file:
.office-location {
display: block;
// set this value to something that makes sense for your design.
max-width: 100px;
}

CSS: Two texts side by side, one fits content, the other shrinks and overflows until min-width then wraps

I have a title and a url one after the other and I want them to be side by side until they fit on the container width. When they can't fit side by side I want the url to shrink and overflow, until it reaches its min-width, then it can wrap.
Within the same container there are other elements that, if possible, I'd like to keep untouched, behaving like inline or flex items.
I tried to achieve this with flexbox, which had to have flex-wrap: wrap in order to make the subsequent elements flow, but the url would either shrink and make the date element come up on the first row (flex-basis: 0) or expand too much until it wrapped to the following line (flex-basis: some%).
I tried to use float and clear, but couldn't get it to work.
Here's what I'm trying to achieve:
desired result
Here's what I'm getting with flexbox:
url not expanding
Here's what I want when the available space is less than the url min-width:
url wrapping to next line
Here's the relevant html code:
<div class="section" data-section="header">
<h5 class="section-title" style="display: none;">Section title</h5>
<div class="field" data-field="title">
<span class="field-label" style="display: none;">Field label</span>
<span class="field-value">
Some variable length, possibly quite long text here
</span>
</div>
<div class="field" data-field="link">
<span class="field-label" style="display: none;">Link</span>
<span class="field-value">
<a href="https://www.example.com/some-path/a-variable-length-and-possibly-quite-long-url-here.html">
https://www.example.com/some-path/a-variable-length-and-possibly-quite-long-url-here.html
</a>
</span>
</div>
<div class="field" data-field="date">
<span class="field-label">Date</span>
<span class="field-value">2018-05-03 00:00:00</span>
</div>
[...]
</div>
And the current CSS:
.section[data-section=header] .field {
display: inline;
}
.section[data-section=header] .field[data-field=title] {
font-weight: 700;
font-size: 1.2em;
line-height: 0.8;
}
.section[data-section=header] .field[data-field=link] {
font-weight: 600;
font-size: 0.7em;
white-space: nowrap;
max-width: 100%;
position: relative;
}
.section[data-section=header] .field[data-field=link] .field-value {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
max-width: calc(100% - .8em);
display: inline-block;
vertical-align: -.1em;
}
.section[data-section=header] .field[data-field=link]::before {
content: "[";
font-size: 1.2em;
}
.section[data-section=header] .field[data-field=link]::after {
content: "]\000A";
white-space: pre;
font-size: 1.2em;
}
.section[data-section=header] .field[data-field=status]::after {
content: "\000A";
white-space: pre;
}
.section[data-section=header] .field[data-field=title]::after {
content: " ";
line-height: 0px;
font-size: 2.8em;
}
Is there any way I can achieve this without resorting to edit the html layout or isolating the title and url into their own container?

Text outside of span, offset from span outline

I'm building a "We the People" website section inspired by the U.S. Constitution, and I'm listing names of "signers" supporting my project. The names have different sizes, and I'm trying to get them to show up nicely on the page. Strangely, the font is consistently offset from the spans containing the names. Here's what I have:
As you can see, the names overlap, which I'd like to avoid. What I find odd is that the text is outside of the span outlines:
The same is true of all the names. Here's my HTML:
<div id="names">
<span class="order ten CalifornyaA-Bold" id="o3">Eric So</span>
<span class="order twenty-five CalifornyaB-Bold" id="o5">Sierra Hansen</span>
<span class="order ten CalifornyaB-Bold" id="o6">Eleanor Collier</span>
...
<span class="order twenty-five CalifornyaC-Bold" id="o69">Maeve McCarty</span>
</div>
... and CSS:
#names {
text-align: center;
padding-bottom: 10%;
}
.hancock, .five-hundred, .two-hundred, .one-hundred, .fifty, .twenty-five, .ten {
line-height: 1.5em;
white-space: nowrap;
}
.hancock {
font-size: 5.5em;
}
.five-hundred {
font-size: 4em;
}
.two-hundred {
font-size: 3.4em;
}
.one-hundred {
font-size: 2.8em;
}
.fifty {
font-size: 2.2em;
}
.twenty-five {
font-size: 1.6em;
}
.ten {
font-size: 1em;
}
Any help would be very much appreciated!
its your line-height since they are inline elements an no block elements, try modifying the value:
.hancock, .five-hundred, .two-hundred, .one-hundred, .fifty, .twenty-five, .ten {
line-height: 110%;//percent would be good
white-space: nowrap;
}
or add individual CSS rules for each one, instead of all being set to1.5em
Edit:
Remember to set a font-size to the parent element since you are using em, check how i wrapped a text and added a font-size in em in the page of the font and its not overlapping:
you can use
span {line-height: 1.2;}
It seems that display: inline-block and then setting margin-top works fairly well. I think that's a bit of a hack solution, but it more or less works.

Having different font sizes in a sentence

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>

Eliminating space between horizontal elements [duplicate]

This question already has answers here:
A space between inline-block list items [duplicate]
(8 answers)
Closed 8 years ago.
I'm trying to generate a web page with a diagram that shows how a word is broken down into bit fields. The way I want it to appear is for each field to appear as a row of boxes (one bit per box), and for the fields to be separated by some space. There will be a label below each field. This is what I've tried:
<HTML>
<HEAD>
<TITLE>Title</TITLE>
<STYLE type="text/css">
.left-bit { border-style: solid dotted solid solid; border-width: thin;
padding-left: 0.05in; padding-right: 0.05in;
margin-left: 0; margin-right: 0;
letter-spacing: 0; word-spacing: 0 }
.middle-bit { border-style: solid dotted solid none; border-width: thin;
padding-left: 0.05in; padding-right: 0.05in;
margin-left: 0; margin-right: 0;
letter-spacing: 0; word-spacing: 0 }
.right-bit { border-style: solid solid solid none; border-width: thin;
padding-left: 0.05in; padding-right: 0.05in;
margin-left: 0; margin-right: 0;
letter-spacing: 0; word-spacing: 0 }
.single-bit { border-style: solid; border-width: thin;
padding-left: 0.05in; padding-right: 0.05in;
margin-left: 0; margin-right: 0;
letter-spacing: 0; word-spacing: 0 }
.bit-field-label { font-size: smaller; font-weight: bold }
</STYLE>
</HEAD>
<BODY>
<DIV style="text-align: center">
<DIV style="text-align: center; vertical-align: top; display: inline-block">
<CODE>
<SPAN class="single-bit">a</SPAN>
</CODE><BR>
<SPAN style="display: inline-block" class="bit-field-label">field A</SPAN>
</DIV>
<SPAN style="padding-right: 0.1in"></SPAN>
<DIV style="text-align: center; vertical-align: top; display: inline-block">
<CODE>
<SPAN class="left-bit">b</SPAN>
<SPAN class="middle-bit">b</SPAN>
<SPAN class="right-bit">b</SPAN>
</CODE><BR>
<SPAN class="bit-field-label">field B</SPAN>
</DIV>
<SPAN style="padding-right: 0.1in"></SPAN>
<DIV style="text-align: center; vertical-align: top; display: inline-block">
<CODE>
<SPAN class="left-bit">c</SPAN>
<SPAN class="middle-bit">c</SPAN>
<SPAN class="middle-bit">c</SPAN>
<SPAN class="middle-bit">j</SPAN>
<SPAN class="right-bit">c</SPAN>
</CODE><BR>
<SPAN class="bit-field-label">field C</SPAN>
</DIV>
</DIV>
</BODY>
</HTML>
Basically, I've tried using borders to set up a box for each bit; each bit field and the label below it are supposed to be in their own "box", with the row of bits and label centered within the box, then there's to be a gap of a fixed size between each box horizontally, and then the whole thing is centered.
The result is almost correct except that I can't get the bits in each field to run up against each other. Here's a screenshot. As you can see, I tried getting rid of the space between bits by setting the margins, letter-spacing, and word-spacing to 0, to no avail. I also tried putting each group into another DIV like this:
<DIV style="display: inline-block">
<SPAN class="left-bit">b</SPAN>
<SPAN class="middle-bit">b</SPAN>
<SPAN class="right-bit">b</SPAN>
</DIV>
which had no effect.
Any ideas on what controls this space between the boxes, and how to override whatever it does? (I'm open to other approaches, and I might have to try some kind of <TABLE>, but I'd appreciate an explanation of what's going on even if I have to change my approach.)
I'm using Chrome 37.0. I haven't tried this on other browsers (except an earlier version of IE which apparently doesn't recognize inline-block at all.)
you could have your HTML cleaner but the problem is the display:inline-block create gaps, so you need to remove unnecessary spaces between your HTML tags or reset font-size to 0.
check it here :
Fighting the Space Between Inline Block Elements
There is more solutions on the link above.
Plus you can use display:block; float:left instead.
combining elements like so will remove the space
<span style="display:inline-block;">Hello</span><span style="display:inline-block;">World</span>
it's a hassle I know but it works somehow. you want to put those styles in an external style sheet, not inline like I have them here.