javascript - CSS styled radio buttons don't respond to keyboard -
i using css style radio buttons ios segmented buttons. not respond keyboard input. missing?
here html of example:
<nav class="segmented-button"> <input type="radio" name="seg-1" value="organisation" id="seg-organisation" checked> <label for="seg-organisation" class="first">organisation</label> <input type="radio" name="seg-1" value="users" id="seg-users"> <label for="seg-users">users</label> <input type="radio" name="seg-1" value="units" id="seg-units" disabled> <label for="seg-units">units</label> <input type="radio" name="seg-1" value="tags" id="seg-tags"> <label for="seg-tags" class="last">tags</label> </nav>
here css
.segmented-button { padding: 12px; } .segmented-button input[type="radio"] { width: 0px; height: 0px; display: none; } .segmented-button label { display: -moz-inline-box; -moz-box-orient: vertical; display: inline-block; vertical-align: middle; *vertical-align: auto; -moz-border-radius: 4px; -webkit-border-radius: 4px; -o-border-radius: 4px; -ms-border-radius: 4px; -khtml-border-radius: 4px; border-radius: 4px; text-shadow: white; background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #e4e4e4)); background: -webkit-linear-gradient(#ffffff, #e4e4e4); background: -moz-linear-gradient(#ffffff, #e4e4e4); background: -o-linear-gradient(#ffffff, #e4e4e4); background: -ms-linear-gradient(#ffffff, #e4e4e4); background: linear-gradient(#ffffff, #e4e4e4); border: 1px solid #b2b2b2; color: #666666; padding: 5px 24px; padding-bottom: 3px; font-size: 12px; cursor: pointer; font-family: helvetica; -moz-border-radius: 0px; -webkit-border-radius: 0px; -o-border-radius: 0px; -ms-border-radius: 0px; -khtml-border-radius: 0px; border-radius: 0px; margin-right: -5px; } .segmented-button label { *display: inline; } .segmented-button label:hover { -moz-box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1); -o-box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1); box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1); color: #333333; } .segmented-button label:active, .segmented-button label.active { background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #e4e4e4), color-stop(100%, #ffffff)); background: -webkit-linear-gradient(#e4e4e4, #ffffff); background: -moz-linear-gradient(#e4e4e4, #ffffff); background: -o-linear-gradient(#e4e4e4, #ffffff); background: -ms-linear-gradient(#e4e4e4, #ffffff); background: linear-gradient(#e4e4e4, #ffffff); } .segmented-button label:disabled, .segmented-button label.disabled { background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #efefef)); background: -webkit-linear-gradient(#ffffff, #efefef); background: -moz-linear-gradient(#ffffff, #efefef); background: -o-linear-gradient(#ffffff, #efefef); background: -ms-linear-gradient(#ffffff, #efefef); background: linear-gradient(#ffffff, #efefef); cursor: default; color: #b2b2b2; border-color: #cccccc; -moz-box-shadow: none; -webkit-box-shadow: none; -o-box-shadow: none; box-shadow: none; } .segmented-button label.first { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -o-border-top-left-radius: 4px; -ms-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -o-border-bottom-left-radius: 4px; -ms-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; } .segmented-button label.last { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -o-border-top-right-radius: 4px; -ms-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -o-border-bottom-right-radius: 4px; -ms-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; } .segmented-button input:checked + label, .segmented-button label.selected { background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #e4e4e4), color-stop(100%, #ffffff)); background: -webkit-linear-gradient(#e4e4e4, #ffffff); background: -moz-linear-gradient(#e4e4e4, #ffffff); background: -o-linear-gradient(#e4e4e4, #ffffff); background: -ms-linear-gradient(#e4e4e4, #ffffff); background: linear-gradient(#e4e4e4, #ffffff); } .segmented-button input:disabled + label { background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #efefef)); background: -webkit-linear-gradient(#ffffff, #efefef); background: -moz-linear-gradient(#ffffff, #efefef); background: -o-linear-gradient(#ffffff, #efefef); background: -ms-linear-gradient(#ffffff, #efefef); background: linear-gradient(#ffffff, #efefef); cursor: default; color: #b2b2b2; border-color: #cccccc; -moz-box-shadow: none; -webkit-box-shadow: none; -o-box-shadow: none; box-shadow: none; }
here fiddle http://jsfiddle.net/schinckel/blkmc/3/light/
don't hide inputs display: none
, of course can't focus element not part of page. try approach:
.segmented-button input[type="radio"] { position: absolute; top: -1000px; }
http://jsfiddle.net/blkmc/34/ (result: http://jsfiddle.net/blkmc/34/embedded/result/)
Comments
Post a Comment