473,395 Members | 1,458 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,395 software developers and data experts.

need help with stylesheet and FireFox

ok, I have a page, where the DOM is being updated by JavaScript.

in the original version, there is a document.write creating the following:
<div id="first" style="position:absolute;top:0px;left:0px">
<div style="position:relative">
<div id="third-1" style="position:absolute;top:0px;left:0;height:-10;width:-10;text-align:center">
<font face="Verdana" size="1" color="#ff0000">
<B>text-1</B>
</font>
</div>
<div id="third-2" style="position:absolute;top:0px;left:0;height:-10;width:-10;text-align:center">
<font face="Verdana" size="1" color="#00ff00">
<B>text-2</B>
</font>
</div>
<div id="third-3" style="position:absolute;top:0px;left:0;height:-10;width:-10;text-align:center">
<font face="Verdana" size="1" color="#0000ff">
<B>text-3</B>
</font>
</div>
</div>
</div>

Don't ask me about the negative height and width attributes in the <div> tags,
but it seemed to work. Also the <font size=1> seemed to work, but now comes the
thing: since <font> is deprecated according to the holy W3C, I decided to remove
the <font> tag and implement a stylesheet.

So I create a "on-the-fly" stylesheet in the script, place it in the DOM <head>
as it should with document.styleSheets and CSS.addRule() or if the agent doesn't
support it, with appendChild(document.createTextNode(CSSSelector+'{ '+CSSProperties+'}'))

Now so far the CSS entries are being created:
AddCSSRule('.third-div','position: absolute; top: 0px; left: 0; height: -10; width: -10; text-align: center');
AddCSSRule('.third-1','font-family: Verdana, sans-serif; font-size: 1; color: #ff0000; font-weight: bold;');
AddCSSRule('.third-2','font-family: Verdana, sans-serif; font-size: 1; color: #00ff00; font-weight: bold;');
AddCSSRule('.third-3','font-family: Verdana, sans-serif; font-size: 1; color: #0000ff; font-weight: bold;');

this creates the following withouth my "#comments":
<style type="text/css">
#the following is for the third nested <div> blocks
.third-div {position: absolute; top: 0px; left: 0; height: -10; width: -10; text-align: center;}
#these three are for the <p> in the third nested <div> blocks
.third-1 {font-family: Verdana, sans-serif; font-size: 1; color: #ff0000; font-weight: bold;}
.third-2 {font-family: Verdana, sans-serif; font-size: 1; color: #00ff00; font-weight: bold;}
.third-3 {font-family: Verdana, sans-serif; font-size: 1; color: #0000ff; font-weight: bold;}
</style>

the document.write is being changed to document.createElement("div") and so on,
which now creates the following:

<div id="first" style="position:absolute;top:0px;left:0px">
<div style="position:relative">
<div id="third-1" class="third-div">
<p class="third-1">text-1</p>
</div>
<div id="third-2" class="third-div">
<p class="third-2">text-2</p>
</div>
<div id="third-3" class="third-div">
<p class="third-3">text-3</p>
</div>
</div>
</div>

now somehow the font size, when used with <p> seems to make the
text on FF illegible small, whereas on IE6 the text seems to have
a normal size.

Can anybody tell me why FF reacts that way? I mean, it worked with
the <font> tag just like IE6, but with the <p> it just doesn't.

What can I change to get the same result as I had before?
but without having the <font> tag reinstated ;-)

thanks for any help
Aug 4 '05 #1
3 1690
Robi wrote:
ok, I have a page, where the DOM is being updated by JavaScript. [...] <font face="Verdana" size="1" color="#ff0000"> [...] Now so far the CSS entries are being created:
AddCSSRule('.third-div','...');
AddCSSRule('.third-1','... font-size: 1; ...');
And here is the problem --------^^^^^^^^^^^^

You can't simply move old font size attribute values to CSS font-size
properties - they are very different things.

[...] now somehow the font size, when used with <p> seems to make the
text on FF illegible small, whereas on IE6 the text seems to have
a normal size.

Can anybody tell me why FF reacts that way? I mean, it worked with
the <font> tag just like IE6, but with the <p> it just doesn't.

What can I change to get the same result as I had before?
but without having the <font> tag reinstated ;-)


When specifying a font-size you have the options listed here:

<URL:http://www.w3.org/TR/REC-CSS2/fonts.html#font-size-props>

The short answer is that if you use a value like '1' you must also use a
unit (px, em, ex, pt, etc.).

Whatever Firefox is interpreting your units as they are small (so
obviously not em or ex, but maybe pt or px).

The solution is to add a unit, px is not liked because IE will not scale
it, so try em or ex (or whatever suits).

[...]

--
Rob
Aug 4 '05 #2
RobG wrote:
Robi wrote:
ok, I have a page, where the DOM is being updated by JavaScript. [...]
<font face="Verdana" size="1" color="#ff0000">

[...]
Now so far the CSS entries are being created:
AddCSSRule('.third-div','...');
AddCSSRule('.third-1','... font-size: 1; ...');


And here is the problem -------^^^^^^^^^^^^

You can't simply move old font size attribute values to CSS font-size
properties - they are very different things.


one would have thunk they'd keep them the same .... ;-)

[...]
What can I change to get the same result as I had before?
but without having the <font> tag reinstated ;-)


When specifying a font-size you have the options listed here:

<URL:http://www.w3.org/TR/REC-CSS2/fonts.html#font-size-props>

The short answer is that if you use a value like '1' you must also use a
unit (px, em, ex, pt, etc.).

ok, hmmmm... well, W3C is somehow 'obscure' about what to use...
but with your list I found lotsa places which explain it better than W3C

Whatever Firefox is interpreting your units as they are small (so
obviously not em or ex, but maybe pt or px).

The solution is to add a unit, px is not liked because IE will not scale
it, so try em or ex (or whatever suits).


Thanks! em did the trick in FF :)
oops, spoke too soon...
that is, until I realized that em is a 'relative' size whereas I need it
'fixed' or 'absolute'... whenever I increase the text size of the page,
my little widget increases its text size and blows it out of proportion.

Is there an attribute "no-resize"?

Aug 5 '05 #3
Robi wrote:
Thanks! em did the trick in FF :)
I prefer percents. Some versions of IE have trouble interpreting em.
oops, spoke too soon...
that is, until I realized that em is a 'relative' size whereas I
need it 'fixed' or 'absolute'... whenever I increase the text size
of the page, my little widget increases its text size and blows it
out of proportion.
Then there are design errors on the rest of the page.
Is there an attribute "no-resize"?


No, and you can't stop a proper user agent from resizing your page,
either. Best you use "relative" sizing for everything.

Have a look at a few of Ben Meadowcroft's templates:
http://www.benmeadowcroft.com/webdev/

--
-bts
-This space intentionally left blank.
Aug 5 '05 #4

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

Similar topics

12
by: Tony Carnell | last post by:
Hi, Here's a conundrum that I hope someone out there can help me solve. I've created a page to XHTML 1.0 Transitional / CSS standards using Macromedia Dreamweaver MX 2004 (and validated both...
19
by: deko | last post by:
Firefox will not take the following "font-weight:bold" directive in my stylesheet. Works fine in IE. #rightMenuText h5 { font-weight:bold; padding-bottom:0px; padding-top: 10px;...
1
by: Bill H | last post by:
I run a dbms application that interfaces with the web. This module creates a frames page with two frames ('main' and 'mwinfoframe'). All communication with the dbms is routed through the...
23
by: AJBopp | last post by:
Ok, I'm trying to be a good little boy and create a site that doesn't use frames :) Things were going along decently until I uploaded what little I have done so far to the web server (that is,...
1
by: ddtraveller | last post by:
Hello, I have a web page that loads up an xml and an xsl page with javascript and displays it. When the user clicks on a link the table is re-sorted according to date or name, etc. I use the same...
4
by: Barry | last post by:
Hello. I am in the process of modifying some JavaScript code which refers to an external stylesheet, but unfortunately I have very little previous JavaScript experience. Currently the code has only...
1
by: Arun dudee | last post by:
I have a xml and xsl file when i run the xml in IE ^ and firefox i have differnt kind of layout for my page.In firefox it gives me what i want but not in iE please help.This my code XML FILE...
1
by: iddjoe | last post by:
I am in the process of converting a web page over to XHTML 1.0 Strict and CSS, as opposed to using tables for layout. I think I am almost there, but I am having issues with borders, some strangely...
3
by: jariwaladivyesh | last post by:
Hi frnds, i have simple XML doc <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="test.xsl"?> <data> <name> Divyesh Jariala</name> </data>
10
by: ellie2905 | last post by:
Hello, I am new to this forum and I am glad I found it because it seems that it will help me with my problem.I have creates a site using jsf components like grid panels and buttons.In the mozilla...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.