Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Can I use DOM in CSS?

Can I use DOM in CSS? I want the set the bgColor of an element to the bgColor of the parent by using CSS – How can I?
0
madchat1
Asked:
madchat1
  • 3
  • 2
1 Solution
 
RoonaanCommented:
You can set the element to be transparent:
#parentDivId element {background:transparent;}

-r-
0
 
madchat1Author Commented:

I tried transparent by it's no good coz in FireFox it doesn't work so well.
(And what does #parentDivId mean? Why do need the parent if it is transparent)

Thanks.
0
 
RoonaanCommented:
The official answer to your question would be: No you cannot use DOM in crossbrowser CSS.

-r-
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
bpmurrayCommented:
Actually, you can use JavaScript in your CSS files. However, it's only executed once, so it may not be just what you want (see http://www.quirksmode.org/css/javascript.html). An alternative is to manipulate the CSS in onPageLoad, where you can set the colors as you wish.
0
 
RoonaanCommented:
@bpmurray,

That is why I wrote it in this way: "No you cannot use DOM in --> crossbrowser CSS <--."

-r-
0
 
bpmurrayCommented:
Yes, Roonan, the embedded JS in CSS only works in IE and Opera (and is regarded as a naughty thing to do). However, the idea of manipulating styles in an onload function is perfectly valid and works across browsers.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now