Solved

Can I use DOM in CSS?

Posted on 2006-07-04
9
213 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Website URL redirection 10 53
Where is the title coming from 6 48
Problem to Popup 2 51
Problem to picture file 3 40
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.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging pā€¦
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

706 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

19 Experts available now in Live!

Get 1:1 Help Now