|
-
May 8th, 2004, 08:20 AM
#1
Thread Starter
Ex-Super Mod'rater
CSS: More than one class
Is it possible to have a tag that belongs to more than one class?
Thanx
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
May 8th, 2004, 08:23 AM
#2
Re: CSS: More than one class
No - but it is possible for tags to inherit CSS properties from a parent tag in another class.
What is it you are trying to do?
-
May 8th, 2004, 08:39 AM
#3
Thread Starter
Ex-Super Mod'rater
I'm using this this javascript to make the item invisible, the HiddenItems class is:
.HiddenItems { VISIBILITY: Hidden; DISPLAY: none; }
I guess a better way to do this would be to the visibility and display in the javascript instead changing the class. The only problem with that is I don't know how I would access these properties using the ID. And I dont know what they should be set to when the item is visible. Any Ideas?
Code:
function Show(IDName)
{
document.getElementById(IDName).className = "";
}
function Hide(IDName)
{
document.getElementById(IDName).className = "HiddenItems";
}
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
May 8th, 2004, 08:51 AM
#4
Frenzied Member
Does it not show again when you run the show function?
BTW, I think this will edit the elements style attribute:
Code:
document.getElementById(IDName).style="VISIBILITY: Hidden; DISPLAY: none;"
Have I helped you? Please Rate my posts. 
-
May 8th, 2004, 08:55 AM
#5
Thread Starter
Ex-Super Mod'rater
That should work, mind if the element already had a class that applied a style to it would that remove it? Like if the style applied a font and color say when I used that to display it again would the text formatting been lost?
And any idea what the Visiblity & display properties should be to make it visible again? Or just removing them should make it visible again ?
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
May 8th, 2004, 08:57 AM
#6
Thread Starter
Ex-Super Mod'rater
Just tested it and I got a member not found error.
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
May 8th, 2004, 09:04 AM
#7
You can set individual styles as followis in javascript:
Code:
element.style.styleName = value
Where the element is a tag object and styleName is the name of the style you want to change. Stylwes such as font-color become fontColor in javascript.
So in you example you could do this:
Code:
function Show(IDName)
{
document.getElementById(IDName).style.visibility = "visible";
document.getElementById(IDName).style.display = "inline";
}
function Hide(IDName)
{
document.getElementById(IDName).style.visibility = "hidden";
document.getElementById(IDName).style.display = "none";
}
-
May 8th, 2004, 09:16 AM
#8
Thread Starter
Ex-Super Mod'rater
Thanx to both of you for your help. I actually changed it to this because using inline made it miss out white space when I tested it.  
Code:
function Show(IDName)
{
document.getElementById(IDName).style.visibility = "visible";
document.getElementById(IDName).style.display = "";
}
function Hide(IDName)
{
document.getElementById(IDName).style.visibility = "hidden";
document.getElementById(IDName).style.display = "none";
}
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
May 8th, 2004, 02:38 PM
#9
It IS possible for a tag to belong to more than one class:
<div class="block hidden">
is entirely valid and makes the div belong to both the block and hidden classes.
Therefore, the rule
div.block {
}
will apply to it, as well as the rule
div.hidden {
}
The rule
div.block.hidden {
}
will indeed apply only to such divs.
Restrictions:
NS4 doesn't understand it. Tags with multiple classes belong to none in NS4's rendering.
IE (any version) doesn't properly understand the third selector above and will apply the rule to everything of the class hidden.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|