473,770 Members | 3,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I change the value in a css class?

How can I change the value in a css class?

For instance, with I.E., I want to change the value in the class
span.arr from middle to 0.2em. The value of middle is OK for most
other browsers.

I expected the code below to work but I.E. does not like it.

What should I be doing?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html;charset=is o-8859-1">
<title>Chemic al Formula Display</title>
<style type="text/css"><!--
body {font-size: 12pt}
p, ol {font-size: 12pt; margin-top: 0.2em; margin-bottom: 0.4em}
h1 {font-size: 18pt}
sub {vertical-align: bottom; font-size: 9pt}
sup {vertical-align: top; font-size: 9pt}
span.arr {vertical-align: middle;}
-->
</style>
<script type="text/javascript"><!--
if (navigator.appN ame == "Microsoft Internet Explorer")
changeStyle("sp an.arr", '0.2em')
else
changeStyle("sp an.arr", 'middle');

function changeStyle(cla ssNme, newContent)
{
var ssheet = document.styleS heets[0];
var ruleList = (typeof ssheet.cssRules != "undefined" ) ?
ssheet.cssRules : ((typeof ssheet.rules != "undefined" ) ? ssheet.rules
: null );
if (ruleList)
for (var i = 0; i < ruleList.length ; i++)
{
if (ruleList[i].selectorText.t oLowerCase() == classNme)
{
ruleList[i].style.vertical-align = newContent;
break;
}
}
}
// -->
</script>
</head>
<body style="text-justify-trim:punctuatio n" lang="EN-GB">
<h1>Chemical Formula Display</h1>
<p>Netscape requires the arrows to be vertically aligned in
the 'middle' but I.E. wants them to be aligned at 0.2em</p>
<p>(I) H<sub>2</sub>SO<sub>4</sub> + Zn <span
class="arr">&hA rr;</span> ZnSO<sub>4</sub> + H<sub>2</sub></p>
<p>(I) H<sub>2</sub>SO<sub>4</sub> + Zn <span
class="arr">&ra rr;</span> ZnSO<sub>4</sub> + H<sub>2</sub></p>
<p style="margin-top=4em"></p>
</body>
</html>
Oct 18 '05 #1
10 2587
On Tue, 18 Oct 2005 09:04:24 GMT, Harry Haller <Ha***@Steppenw olf.com>
wrote:
How can I change the value in a css class?

For instance, with I.E., I want to change the value in the class
span.arr from middle to 0.2em. The value of middle is OK for most
other browsers.

I expected the code below to work but I.E. does not like it.

What should I be doing?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type"
content="tex t/html;charset=is o-8859-1">
<title>Chemic al Formula Display</title>
<style type="text/css"><!--
body {font-size: 12pt}
p, ol {font-size: 12pt; margin-top: 0.2em; margin-bottom: 0.4em}
h1 {font-size: 18pt}
sub {vertical-align: bottom; font-size: 9pt}
sup {vertical-align: top; font-size: 9pt}
span.arr {vertical-align: middle;}
-->
</style>
<script type="text/javascript"><!--
if (navigator.appN ame == "Microsoft Internet Explorer")
changeStyle("sp an.arr", '0.2em')
else
changeStyle("sp an.arr", 'middle');

function changeStyle(cla ssNme, newContent)
{
var ssheet = document.styleS heets[0];
var ruleList = (typeof ssheet.cssRules != "undefined" ) ?
ssheet.cssRule s : ((typeof ssheet.rules != "undefined" ) ? ssheet.rules
: null );
if (ruleList)
for (var i = 0; i < ruleList.length ; i++)
{
if (ruleList[i].selectorText.t oLowerCase() == classNme)
{
ruleList[i].style.vertical-align = newContent;
break;
}
}
}
// -->
</script>
</head>
<body style="text-justify-trim:punctuatio n" lang="EN-GB">
<h1>Chemical Formula Display</h1>
<p>Netscape requires the arrows to be vertically aligned in
the 'middle' but I.E. wants them to be aligned at 0.2em</p>
<p>(I) H<sub>2</sub>SO<sub>4</sub> + Zn <span
class="arr">&h Arr;</span> ZnSO<sub>4</sub> + H<sub>2</sub></p>
<p>(I) H<sub>2</sub>SO<sub>4</sub> + Zn <span
class="arr">&r arr;</span> ZnSO<sub>4</sub> + H<sub>2</sub></p>
<p style="margin-top=4em"></p>
</body>
</html>


Sorry, I just noticed it should be:
ruleList[i].style.vertical Align = newContent;
not
ruleList[i].style.vertical-align = newContent;

Apart from that I have changed all the styles to end with a ;

It works now.
Oct 18 '05 #2
Harry Haller wrote:
How can I change the value in a css class?

For instance, with I.E., I want to change the value in the class
span.arr from middle to 0.2em. The value of middle is OK for most
other browsers.

I expected the code below to work but I.E. does not like it.

What should I be doing?


Ask in a CSS forum, I suspect there is a pure CSS solution. Any
browser-sniffing method is bound to fail at least some of the time for
some browsers.
comp.infosystem s.www.authoring.stylesheets

--
Rob
Oct 18 '05 #3
You can use conditional comments at IE.

Example HTML:
<head>
<style type="text/css"><!--
span.arr {vertical-align: middle;}
--></style>
<!--[if IE]>
<style type="text/css">
span.arr {vertical-align: 0.2em;}
</style>
< ![endif]-->
</head>

This is valid HTML.

Oct 18 '05 #4
Harry Haller wrote:
How can I change the value in a css class?

For instance, with I.E., I want to change the value in the class
span.arr from middle to 0.2em. The value of middle is OK for most
other browsers.
Have you decided on a solution without really considering the actual
problem?
What should I be doing?
We can tell you, but you might not like it. ;)
<style type="text/css"><!--
Dump the <!-- --> comment tags. They haven't been needed for more than
10 years now.

BTW, it is accepted practice to post the URL of a page showing the
problem. Most people don't want to be bothered to copy and paste your
code and dummy up their own page. Besides, more often than not, the code
alone doesn't tell the whole story.

Make it easy for people to help you and you'll get better results.
body {font-size: 12pt}
If this were a print stylesheet, setting font sizes in pt units could be
acceptable. They are unsuitable for screen display, though. Use % per
published accessiblity guidelines, with body at 100%. Subscripts and
superscripts can be a fraction of that, maybe 75%.
span.arr {vertical-align: middle;}

<p>(I) H<sub>2</sub>SO<sub>4</sub> + Zn <span
class="arr">&hA rr;</span> ZnSO<sub>4</sub> + H<sub>2</sub></p>


Seems to me that arrows vertically align by themselves just fine. Why do
you need to specifically set it at all?

BTW, you might want to check out the line-height property.

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Oct 18 '05 #5
Once upon a time *Gomolyako Eduard* wrote:
You can use conditional comments at IE.


Who?

For furter ref on how to post on usenet, please read the links in my sig!

--
/Arne
Now killing all top posters and posters who don't quote
* How to post: http://www.cs.tut.fi/~jkorpela/usenet/brox.html
* From Google: http://www.safalra.com/special/googlegroupsreply/
-------------------------------------------------------------
Oct 18 '05 #6
Taked into consideration.

Arne писал(а):
Once upon a time *Gomolyako Eduard* wrote:
You can use conditional comments at IE.


Who?

For furter ref on how to post on usenet, please read the links in my sig!

--
/Arne
Now killing all top posters and posters who don't quote
* How to post: http://www.cs.tut.fi/~jkorpela/usenet/brox.html
* From Google: http://www.safalra.com/special/googlegroupsreply/
-------------------------------------------------------------


Oct 18 '05 #7
kchayka wrote:
Harry Haller wrote:
<style type="text/css"><!--


Dump the <!-- --> comment tags. They haven't been needed for more than
10 years now.


1. They are NOT "comment tags".ss

2. Your statement applies to _`script'_ elements. JavaScript within HTML
has been around since 1994 (NN2).

HTML 4 and CSS have been around since 1999, it is not that unlikely that
there is an installed user agent that does not understand the `style'
element (properly). Since those comments do no harm in HTML (they are
specified in the CSS grammars in contrast to the JS specs) it is
perfectly valid to use them.
X-Post & F'up2 comp.infosystem s.www.authoring.html

PointedEars
--
The German psychs, the German authorities, the German secret service agents
are [...] fanatics, they are insane and known of persecuting innocent people
and Scientologists. -- "The only real Barbara Schwarz", dsw.scientology ,
<16************ **************@ posting.google. com>
Oct 21 '05 #8
On Tue, 18 Oct 2005 09:15:51 -0500, kchayka <us****@c-net.us> wrote:
Harry Haller wrote:
How can I change the value in a css class?

For instance, with I.E., I want to change the value in the class
span.arr from middle to 0.2em. The value of middle is OK for most
other browsers.


Have you decided on a solution without really considering the actual
problem?
What should I be doing?


We can tell you, but you might not like it. ;)


Heh, why won't I like it? Thank you for taking the time to post. I
appreciate it. I will give very careful consideration to everything
you wrote.

Nov 7 '05 #9
On 18 Oct 2005 06:25:38 -0700, "Gomolyako Eduard"
<ed************ **@gmail.com> wrote:
You can use conditional comments at IE.

Example HTML:
<head>
<style type="text/css"><!--
span.arr {vertical-align: middle;}
--></style>
<!--[if IE]>
<style type="text/css">
span.arr {vertical-align: 0.2em;}
</style>
< ![endif]-->
</head>

This is valid HTML.


It works with Firefox but with IE the last tag, < ![endif]-->, is
displayed at the top of the document. Although, at least the class is
re-defined for IE.

Below is no better, because the css class re-definition is just
ignored.

<head>
<style type="text/css">
span.arr {vertical-align: middle;}
<!--[if IE]>
span.arr {vertical-align: 0.2em;}
< ![endif]-->
</style>
</head>

Nov 7 '05 #10

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

Similar topics

2
14300
by: fish | last post by:
Hi, I have an HTML page with a FORM and some input fields. On the fields I wish to do validation as the punters change the field values. If they get it wrong, then I tell them and then wish to put the focus back to the offending field. ( It works if a use an 'onblur' event but not an 'onchange' )
3
5015
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change data in the text boxes. Then an "update" button saves the data back to the database. What is the best way to change several properties on most of the textbox controls on the form when the "modify" button is clicked? (e.g. make them editible (and...
10
27016
by: rob | last post by:
I have a class that among others exposes a string property "Date". The date in this property is stored in the form yyyymmdd. Now I do the following 1) Generate a DataGridViewTextBoxColumn column for that property 2) Add the column to the datagridview 3) Populate a BindingSource by adding all instances of the above mentioned class. 4) Assign the BindingSource to the datagridview's DataSource property
0
2493
by: zeng.hui.stephen | last post by:
I download the demo http://msdn.microsoft.com/msdnmag/issues/02/10/cuttingedge/. I inherite the demo, and write my code. I want to use Hook to monitor C++ Edit change. I use a C# form containing a Edit(textbox) and button to test at first. When I change text in Edit or press button to setText value, I want to monitor the change event. But the event code always return 0, why?
2
2194
cassbiz
by: cassbiz | last post by:
I may be in the wrong forum so Ronald don't shoot :) In my code I have an option box to choose a number - works fine. I want to carry over the new value to another field to do a recalculation. Primarily the field "$preis1" to change with the javascript. Here is the code. <script type="text/javascript">
45
18901
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies of their elements? Why can't I change the element itself? class Program { private struct MyStruct
3
1472
by: tc | last post by:
I'm trying to put together a small control. It's not, but for arguments sake, let's say it's a progress bar. The user will make a change to a setting, lets call it 'value'. I want to trap the change of the public variable in the controls code so I can act on that change. How would I do that?
4
2335
by: CDMAPoster | last post by:
In: http://groups.google.com/group/comp.databases.ms-access/msg/f06bd4c45037ef29 Lyle wrote: :Terry Kreft wrote: : :>Suck it and See? :
2
1527
by: C. Herzog | last post by:
Hi! I want to create a huge amount of classes. All classes have in common that the change of a property should fire an Change-Event and maybe do other things. I don't want to write thousand times the same things like that: Public Property Price() As Double Get
0
9591
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10057
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9869
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.