[RESOLVED] overrid style
What is the proper way of override a CSS style?
One of my greasemonkey scripts simple deletes the class name then applies a "style" element directly. Buts its obviously not proper method....
edit: Maybe one method would be to use HTML DOM to create a style in that page then simple add that to the "class"....
Last edited by whatsInaName; 05-14-2009 at 06:46 AM.
oops, I found my mistake and I just learned something...
I was setting the background to the TR, and nothing was happening until I removed the external CSS file. It was resolving my issue because the external CSS was not altering the TR it was altering the TD instead so firefox was giving that style a priority even tho it was from an external file way the hell up the chain.
edit: But that kind of sucks... because it means I need to manually add a style for every single TD....
Last edited by whatsInaName; 05-14-2009 at 06:48 AM.
the priority is (for all the browsers)
- local style
Classes have also a priority (compounded than simple)
well I was aware about that...
but I was not aware that the TR background that came from "css-on-the-fly" was not taking priority over a css class because it was effecting the TD (the child of the TD).
Looking at this over.... I think ill use JS (HTML DOM) to insert something called "myclass123" style with a background from my TD, then simple add that class to each TR that I want to change.... It will take priority over whatever and it will let me alter the TD.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
var cells=document.getElementById('mytab').getElementsByTagName('td'), i=0, c;
<table id="mytab" width="300" border="1" cellspacing="0" cellpadding="0">
well that is kind of over kill for what I want... in my script there are about 100 rows while all rows have many cells. Then based on certain data I want to change the color (and its not based on a click).
Ive alreaady coded my solution. I simple create a style element, add the "type" attribute then the css using "innerHTML". From there I simple did "myell.className += " styleName"".
Works good. Its less code then my previous stuff + now the page actually displays all the other CSS that I had removed :P
Last edited by whatsInaName; 05-14-2009 at 07:29 AM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)