html - Using Meiryo font causes input field to stretch -
i using famous japanese font called "meiryo" on japanese website. however, usage of font causes input fields stretch. strange bug, if replace font else, input fields normal.
anybody can explain me why bug occurs please?
tested on major browsers
it’s not bug. <input type=text>
element has visible size set size
attribute (defaulted 20), sets width in “characters”. means “average width” characters according html 4, whereas html5 drafts “the user agent should ensure @ least many characters visible”. reality varies across browsers. in case, visible width of element should depend , depends on properties of font – on widths of glyphs in it.
the following simple test (which assumes common default font used input
) illustrates this:
<input value="hello world"><br> <input value="hello world" style="font-family: meiryo">
the latter element considerably wider, , looking @ appearance of initial text, set can see reason that: in meiryo, characters (glyphs) wider in fonts commonly used default input
fonts.
the conclusions depend on page design , layout. in flexible design, details of layout adapt requirements of data , fonts, rather other way around. if design more rigid, might consider setting upper limit on width in css, using pixels if must, e.g. max-width: 200px
.
Comments
Post a Comment