Re: Toggling visibility in css, not javascript

Discussion in 'HTML' started by cwdjrxyz, Aug 5, 2008.

  1. cwdjrxyz

    cwdjrxyz Guest

    On Aug 4, 1:23 pm, Chris <> wrote:
    > Is there a way that I can toggle the visibility of a div on and off
    > using css alone? It's a bit inconvenient in our app to use javascript here.
    >
    > Googling around, I found two tricks, neither of which quite does it. One
    > toggles visibility on hover, and the other creates a dummy checkbox,
    > styles it so it doesn't look like a checkbox, and then has different
    > styles for the checked/unchecked states. Clever, but it's hard to use
    > checkboxes like this in our app.
    >
    > I'm thinking the challenge here is to maintain state using css alone.
    > Probably not possible, but thought I'd ask.


    As others have indicated, it seems you can do this with css alone
    without JavaScript and have your code work as intended on most popular
    current browsers.

    If you can use php on your server, it is likely you could do this
    server side with php. It quite often is possible to do the same thing
    with php server side as it is to do it with JavaScript on the browser.
    And you usually do not have to worry about the response of different
    browsers and if the viewing browser has script turned on or off. I do
    not know the details of your code, but I have used php to turn
    visibility on and off on some of my pages.
     
    cwdjrxyz, Aug 5, 2008
    #1
    1. Advertising

  2. cwdjrxyz

    cwdjrxyz Guest

    On Aug 4, 8:26 pm, cwdjrxyz <> wrote:
    > On Aug 4, 1:23 pm, Chris <> wrote:
    >
    > > Is there a way that I can toggle the visibility of a div on and off
    > > using css alone? It's a bit inconvenient in our app to use javascript here.

    >
    > > Googling around, I found two tricks, neither of which quite does it. One
    > > toggles visibility on hover, and the other creates a dummy checkbox,
    > > styles it so it doesn't look like a checkbox, and then has different
    > > styles for the checked/unchecked states. Clever, but it's hard to use
    > > checkboxes like this in our app.

    >
    > > I'm thinking the challenge here is to maintain state using css alone.
    > > Probably not possible, but thought I'd ask.

    >
    > As others have indicated, it seems you can do this with css alone
    > without JavaScript and have your code work as intended on most popular
    > current browsers.
    >
    > If you can use php on your server, it is likely you could do this
    > server side with php. It quite often is possible to do the same thing
    > with php server side as it is to do it with JavaScript on the browser.


    The above should read:
    "As others have indicated, it seems you can not do this with css alone
    without JavaScript and have your code work as intended on some popular
    current browsers." - sorry


    > And you usually do not have to worry about the response of different
    > browsers and if the viewing browser has script turned on or off. I do
    > not know the details of your code, but I have used php to turn
    > visibility on and off on some of my pages.
     
    cwdjrxyz, Aug 5, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2lhag==?=

    Toggling Image

    =?Utf-8?B?c2lhag==?=, May 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    433
    =?Utf-8?B?U2hhbmU=?=
    May 6, 2005
  2. Replies:
    1
    Views:
    390
    jasonkester
    Jul 7, 2005
  3. C A Upsdell
    Replies:
    2
    Views:
    481
    C A Upsdell
    Aug 5, 2008
  4. richard
    Replies:
    3
    Views:
    504
    cwdjrxyz
    Aug 6, 2008
  5. Machi
    Replies:
    1
    Views:
    342
    Ray at
    Apr 15, 2004
Loading...

Share This Page