RSS Forums RSS
Please support our HTML and CSS advertiser: Lunarpages Web Hosting

CSS pseudo-letter ???

Join Date: Dec 2004
Posts: 1,592
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 35
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: CSS pseudo-letter ???

  #7  
May 2nd, 2006
The parent-child selector won't help. Don't give up on what I've posted.

For FireFox, it is entirely CSS. The script compensates for IE, using JavaScript. The script isn't that hard to understand; it's only a few lines long.

<script type="text/javascript"
function doChangeClassName()
{
    var x = document.getElementsByTagName('div');
    for (var i=0;i<x.length;i++)
    {
        x[i].childNodes[1].className = "ie_p";
    }
}
</script>

The trick is to place your headers and paragraphs into DIV elements.

The first line of the function stores all the DIV elements inside a variable, "x".

Next comes the "for loop", which steps from one DIV to the next, counting them, and storing the count in a variable, "i".

Inside the loop, we look for the second element inside the DIV. The header is the first, the first paragraph is the second. We start counting at "0", so the line x[i].childNodes[1].className = "ie_p"; means "set the class of the first paragraph in this div equal to the 'ie_p' style declaration".

That's it. Oh, and to run this script, there is this little bit at the bottom:

<script>doChangeClassName();</script>

It's very simple, very elegant, and introduces no noticable delay.

If you're attempting to develop CSS skills, then you shouldn't neglect Javascript skills. Both are required to be a successful web designer.
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 4:57 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC