473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Firefox browser problem: width:30ex does not respect font

Look at this page
http://xahlee.org/emacs/wrap-url.html
Look at it in Firebox, look at it in Safari, in Opera, and look at it
in Microsoft Internet Explorer.

The only fucked up case, is Firefox.
Namely, that it does not respect the font used when dealing with
«width:80ex».
The way to test this visually, is by this code:
<pre style="border:thin black solid;
width:30ex">iiiiiiiiiiiiiiiiiiiiiiiiiiiiii</pre>

See also:
http://xahlee.org/UnixResource_dir/w...e_license.html
http://xahlee.org/UnixResource_dir/w..._attitude.html

Xah
xa*@xahlee.org
∑ http://xahlee.org/

Oct 11 '06 #1
7 4618
On 2006-10-11, Xah Lee <xa*@xahlee.orgwrote:
Look at this page
http://xahlee.org/emacs/wrap-url.html
Look at it in Firebox, look at it in Safari, in Opera, and look at it
in Microsoft Internet Explorer.

The only fucked up case, is Firefox.
Namely, that it does not respect the font used when dealing with
«width:80ex».
The way to test this visually, is by this code:
<pre style="border:thin black solid;
width:30ex">iiiiiiiiiiiiiiiiiiiiiiiiiiiiii</pre>
It does respect the font. Try it with a few fonts-- the width of the box
varies.

"ex" is a measurement of font _height_. The font used for <preis often
something like Courier, in which the x is short and fat. So 30 x-heights
is not wide enough for 30 'x's.

Note also that if the user isn't using a monospaced font for <pre(they
usually do, but don't have to) this wouldn't work even if 1ex were the
width of an ex.

You can fix your problem instead by using a shrink-to-fit box by making
it absolutely positioned, floated, or using a table. Obviously the
content may need other changes if these have other unwanted sideeffects.
Oct 11 '06 #2
Ben C wrote:
« It does respect the font. Try it with a few fonts-- the width of the
box varies.»

Thanks. I just created a page here and tested it:
http://xahlee.org/js/width-ex.html

You are right that Firefox respect font when considering ex.
However, it turns out, FireFox is still incorrect. While, Safari and
Opera are correct. (the iCab browser does the worst here. It doesn't
respect font at all)

«You can fix your problem instead by using a shrink-to-fit box by
making it absolutely positioned, floated, or using a table. Obviously
the content may need other changes if these have other unwanted
sideeffects.»

mm... interesting suggestions. Thanks. One thing that won't work with
FireFox is display:table. When using display:table, FireFox will omit
spaces between adjacent <span>, and it will also render line breaks
inside <preincorrectly.
(see here for the former:
http://xahlee.org/js/linebreak_after_tag.html)

(IE doesn't shrink wrap the border for display:table at all)

Perhaps i'll try floated or absolutely positioned...

Xah
xa*@xahlee.org
∑ http://xahlee.org/
Ben C wrote:
On 2006-10-11, Xah Lee <xa*@xahlee.orgwrote:
Look at this page
http://xahlee.org/emacs/wrap-url.html
Look at it in Firebox, look at it in Safari, in Opera, and look at it
in Microsoft Internet Explorer.

The only fucked up case, is Firefox.
Namely, that it does not respect the font used when dealing with
«width:80ex».
The way to test this visually, is by this code:
<pre style="border:thin black solid;
width:30ex">iiiiiiiiiiiiiiiiiiiiiiiiiiiiii</pre>

It does respect the font. Try it with a few fonts-- the width of the box
varies.

"ex" is a measurement of font _height_. The font used for <preis often
something like Courier, in which the x is short and fat. So 30 x-heights
is not wide enough for 30 'x's.

Note also that if the user isn't using a monospaced font for <pre(they
usually do, but don't have to) this wouldn't work even if 1ex were the
width of an ex.

You can fix your problem instead by using a shrink-to-fit box by making
it absolutely positioned, floated, or using a table. Obviously the
content may need other changes if these have other unwanted sideeffects.
Oct 13 '06 #3
On 2006-10-13, Xah Lee <xa*@xahlee.orgwrote:
Ben C wrote:
« It does respect the font. Try it with a few fonts-- the width of the
box varies.»

Thanks. I just created a page here and tested it:
http://xahlee.org/js/width-ex.html

You are right that Firefox respect font when considering ex.
However, it turns out, FireFox is still incorrect. While, Safari and
Opera are correct. (the iCab browser does the worst here. It doesn't
respect font at all)
I looked at the example on your page in Firefox 1.0.7. Where it says
"Firefox Bug", I measured the 70ex box (with the KDE screen ruler) and
made it 490px wide. I then measured the height of one of the x glyphs
and made it 7px. 7x70 = 490, so that looks right.

But it depends on the font. If you're using Firefox on a different OS,
or even on a different Linux distribution, you may not have exactly the
same font. Safari and Opera may not be using the same fonts as
Firefox on your system.

Some fonts may report the height of an 'x' incorrectly. Some fonts don't
even have an 'x' (most languages after all don't have an 'x') but you
can still size things in ex units.
«You can fix your problem instead by using a shrink-to-fit box by
making it absolutely positioned, floated, or using a table. Obviously
the content may need other changes if these have other unwanted
sideeffects.»

mm... interesting suggestions. Thanks. One thing that won't work with
FireFox is display:table. When using display:table, FireFox will omit
spaces between adjacent <span>, and it will also render line breaks
inside <preincorrectly.
(see here for the former:
http://xahlee.org/js/linebreak_after_tag.html)
That does look like it might be a bug.

Easily worked around though by putting the newline instead before you
open the <span(or after you close it).
(IE doesn't shrink wrap the border for display:table at all)
You could also try display: table-cell.
Perhaps i'll try floated or absolutely positioned...
Float is probably the easiest.

The main drawback in this case with position: absolute is that it takes
the positioned box "out of the flow", so the next block box goes
behind it instead of below it.

If you give the float its own block box, and make sure it's cleared at
the bottom, it should behave identically to a normal block box but with
shrink-to-fit width.

Something like this:

<div>
Here is the code:
</div>
<div>
<pre style="float: left; background-color: seashell;">
blah blah
blah
</pre>
<span style="clear: left"></span>
</div>
<div>
Next bit of text
</div>
Oct 13 '06 #4
Ben C wrote:
>
Some fonts may report the height of an 'x' incorrectly.
And several browsers just use the value of .5em instead of the actual
x-height. Firefox is one of the few that actually get this right.

--
Berg
Oct 13 '06 #5
is there a way to make the various tool bars in FireFox vertical or
pull off?
e.g. on the side like in IE or Opera?

I have tabs, web dev tool bar, bookmark bar, nav bar, stumbleupon bar,
and they take too much space on top.

Xah
xa*@xahlee.org
∑ http://xahlee.org/

Nov 1 '06 #6
There are extensions for this...

pxclassic.net/misc/tbx.xpi

To use this, create a new toolbar (View>Toolbars>Customize...>Add New
Toolbar), then drag and drop your navbar buttons etc to the new
toolbar(s). Then right-click the new bar and choose the location.
Uncheck Navigation Toolbar under View>Toolbars and your done.

For tabs, TMP gives you an option to display tabs on the side or
bottom...

http://tmp.garyr.net/forum/viewtopic.php?t=2582

Hope that helps.

~hhh
Xah Lee wrote:
is there a way to make the various tool bars in FireFox vertical or
pull off?
e.g. on the side like in IE or Opera?

I have tabs, web dev tool bar, bookmark bar, nav bar, stumbleupon bar,
and they take too much space on top.

Xah
xa*@xahlee.org
∑ http://xahlee.org/
Nov 1 '06 #7
There is a more modern extension for doing this:

Toolbar Control

http://webdesigns.ms11.net/chromeditp.html#toolbarc
Hass wrote:
There are extensions for this...

pxclassic.net/misc/tbx.xpi

To use this, create a new toolbar (View>Toolbars>Customize...>Add New
Toolbar), then drag and drop your navbar buttons etc to the new
toolbar(s). Then right-click the new bar and choose the location.
Uncheck Navigation Toolbar under View>Toolbars and your done.

For tabs, TMP gives you an option to display tabs on the side or
bottom...

http://tmp.garyr.net/forum/viewtopic.php?t=2582

Hope that helps.

~hhh
Xah Lee wrote:
is there a way to make the various tool bars in FireFox vertical or
pull off?
e.g. on the side like in IE or Opera?

I have tabs, web dev tool bar, bookmark bar, nav bar, stumbleupon bar,
and they take too much space on top.

Xah
xa*@xahlee.org
∑ http://xahlee.org/
Nov 2 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Arthur Connor | last post by:
I want to embed some source code lines in an article on a web page. As usual I want to use a fixed sized font for this souce code lines (read: the letters should have all the same width). The...
8
by: McKirahan | last post by:
Firefox does not reflect selected option via innerHTML How do I get Firefox to reflect selected option values? <html> <head> <title>FFinner.htm</title> <script type="text/javascript">...
2
by: dlgproc | last post by:
I wanted to display text in a label on a Windows form in a fixed-width font. In C++ Windows API programming I’ve always used: GetStockObject(SYSTEM_FIXED_FONT). Using the following C# code...
3
by: Urs Eichmann | last post by:
Hello I have an ASP.NET web site where you can page through lists by using INPUT TYPE=image buttons. I noticed that, in IE6, the whole page gets cleared and built again from the ground up, whereas...
3
by: Noozer | last post by:
I need a fast "console" type control. Basically a textbox that uses a fixed width font and can be configured for a specific width and height. I may need to apply colour and double width & height...
7
by: sonnystarks | last post by:
Page construction in progress: http://www.sdisplay.info/test/ Firefox does not recognize background image referred to on styles.css IE sees it with no problem. What is the problem? Thanx,
8
by: hyejin | last post by:
I have a problem with dynamic iframe and document.close() on Firefox. Below two files create a dynamic iframe by JavaScript. These two samples do not have any problems on IE. But, on Firefox, the...
10
by: Xah Lee | last post by:
Look at this page http://xahlee.org/emacs/wrap-url.html Look at it in Firebox, look at it in Safari, in Opera, and look at it in Microsoft Internet Explorer. The only fucked up case, is...
17
by: ur.solame | last post by:
I have an image being generated by a PHP script-- I didn't write the code-- and the image itself is in a database. I've discovered that there is a big discrepancy between how the images appear...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.