Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I disable a input button using CSS? 1

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
0
0
US
I have an unordered list with several sets of buttons (sprites). I want to be able to setup a style to handle the disabled effect for all buttons. Each set of buttons (sprites) contains an enabled state and a disabled state. My style sheet looks something like the following and it works...sort of. The line in red works but only for btn1.

ul.MyNavMenu {list-style-type: none; display: inline; ...}

ul.MyNavMenu input[type="button"][disabled] {background-position: 0 -16px background-image:url(btn1.png)...}


ul.MyNavMenu li input:Btn1 {background-image:url(btn1.png) ...}
ul.MyNavMenu li input:Btn2 {background-image:url(btn2.png) ...}
ul.MyNavMenu li input:Btn3 {background-image:url(btn3.png) ...}

What is the syntax so that I can get it to work for all of the buttons? I have tried this syntax (with no luck)

ul.MyNavMenu input[type="button"][disabled].btn1 {...}


 
I can't get my example to work. But since you have, I must have syntax wrong some place or code that's interferring with it. I will recheck (again) what I'm doing.

I appreciate your time on this.
 
If you try the example I posted does it work like that? Do the disable buttons show the correct colors?

If they do, the I would wager it has something to do with the way you are disabling your buttons.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
It works!! Thank you for taking the time to prove that what I was doing was correct. I don't know what I did that caused it not to work. I even had one of my coworkers look over my code. Tonight I just tried it again and it worked. Thanks again.
 
Well, maybe not. The syntax works when the type of the input tag is text. However, it doesn't appear to work when the type is button and my css has a background image.
Code:
ul.MyNavMenu li input[type="button"][disabled].clsFirstRecord {background-position: 0 -32px; border: 0px solid transparent; }
 
Oooops. I posted the wrong code in my last post. Should be:
Code:
ul.MyNavMenu li input[type="button"][disabled].clsFirstRecord {background-position: 0 -32px; border: 0px solid transparent; background-image:url(MySpriteImage.png); background-repeat: no-repeat;}
 
OK, maybe it does work. Syntax error on my part. It's late and I dozed off with my finger on the keyboard and inserted a bunch of characters that I didn't notice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top