Solved

Can I use DOM in CSS?

Posted on 2006-07-04
9
214 Views
Last Modified: 2013-11-19
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
Comment
Question by:madchat1
  • 3
  • 2
9 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 17040304
You can set the element to be transparent:
#parentDivId element {background:transparent;}

-r-
0
 

Author Comment

by:madchat1
ID: 17040325

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
 
LVL 49

Accepted Solution

by:
Roonaan earned 125 total points
ID: 17040348
The official answer to your question would be: No you cannot use DOM in crossbrowser CSS.

-r-
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 15

Expert Comment

by:bpmurray
ID: 17041558
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
 
LVL 49

Expert Comment

by:Roonaan
ID: 17041634
@bpmurray,

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

-r-
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 17041785
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now