Results 1 to 9 of 9

Thread: CSS: More than one class

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    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.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    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.

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    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.

  5. #5

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    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.

  6. #6

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    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.

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    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";
    }
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    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.

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width