简体   繁体   中英

Twitter Bootstrap Button Active State

I am almost exclusively using <a> tags with a class of "btn" for the buttons in my web app.

The problem is that when users use the <tab> key to navigate form fields, there is no way to identify when one of these "buttons" has the focus, which is frustrating them.

I tried adding this to the CSS:

a.btn:active{background-color:red;}

But that doesn't really do what I want; That only changes the background color while the button is being clicked. It doesn't affect how the button appears when the button receives the focus via the <tab> key.

I also tried using :focus instead of :active, but that doesn't really work either.

Does anyone know of a way I could globally change this in my app?

:focus is the way to go. Maybe Twitter bootstrap is overriding your :focus styles.

http://jsfiddle.net/4aVuK/2/

Maybe try to add !important in your css.

a.btn:focus{background-color:red !important;}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM