开发者

css buttons and states

Can you apply :hover and :active attributes to input[type=button], or d开发者_运维百科o you have to use a class?


You can...* with exceptions. IE6 ONLY supports :hover on a attributes. If you are supporting IE6, you will need to change the class with JS, if not, you can just use :hover (there are also some IE6 hacks available to bypass this)


Most modern browsers allow you to use :hover with any element, but IE is a bit more fiddly about it.

You can use this hack, or do it with Javascript and event handlers (preferable, IMO).


Yes, you can.

<!DOCTYPE html>
<html> 
    <head> 
        <style type="text/css">
        input[type=button]:hover {
            background: red;
        }
        </style>
    </head>
    <body> 
        <input type="button" value="Hit me" />
    </body>
</html>

Of course, beware of IE, but that's a whole different branch of web design. :)


May I suggest a google link. http://cssbutton.com/forms/ with some examples. You will find that older IE versions are picky with this sort of thing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜