css - CSS3 custom checkbox - cross-browser differences -
i've been working on custom checkboxes while , have found challenge. however, i'm close finishing them , had been testing lot in chrome managed them perfect.
i checked in other browsers , there distinct differences in how after state rendered. how fix differences? possible? or have use image?
html:
<div class="fb-checkbox"> <br> <br> <input id="item21_0_checkbox" name="project_type[]" type="checkbox" data-hint="" value="conference" /><label for="item21_0_checkbox" id="item21_0_label" ><span id="item21_0_span" class="fb-fieldlabel">conference</span></label> <input id="item21_1_checkbox" name="project_type[]" type="checkbox" value="incentive campaign" /><label for="item21_1_checkbox" id="item21_1_label" ><span id="item21_1_span" class="fb-fieldlabel">incentive campaign</span></label> <input id="item21_2_checkbox" name="project_type[]" type="checkbox" value="incentive travel" /><label for="item21_2_checkbox" id="item21_2_label" ><span id="item21_2_span" class="fb-fieldlabel">incentive travel</span></label> <input id="item21_3_checkbox" name="project_type[]" type="checkbox" value="awards dinner" /><label for="item21_3_checkbox" id="item21_3_label" ><span id="item21_3_span" class="fb-fieldlabel">awards dinner</span></label> <input id="item21_4_checkbox" name="project_type[]" type="checkbox" value="product launch" /><label for="item21_4_checkbox" id="item21_4_label" ><span id="item21_4_span" class="fb-fieldlabel">product launch</span></label> <input id="item21_5_checkbox" name="project_type[]" type="checkbox" value="hospitality" /><label for="item21_5_checkbox" id="item21_5_label" ><span id="item21_5_span" class="fb-fieldlabel">hospitality</span></label> <input id="item21_6_checkbox" name="project_type[]" type="checkbox" value="comms , marketing" /><label for="item21_6_checkbox" id="item21_6_label" ><span id="item21_6_span" class="fb-fieldlabel">comms , marketing</span></label> <input id="item21_7_checkbox" name="project_type[]" type="checkbox" value="reward & recoginition scheme" /><label for="item21_7_checkbox" id="item21_7_label" ><span id="item21_7_span" class="fb-fieldlabel">reward & recoginition scheme</span></label> <input id="item21_8_checkbox" name="project_type[]" type="checkbox" value="design brief" /><label for="item21_8_checkbox" id="item21_8_label"><span id="item21_8_span" class="fb-fieldlabel">design brief</span></label> </div>
css:
input[type="checkbox"] { display: none!important; } /*------ 1st checkboxes ----*/ input[type="checkbox"]:not(:checked) + label span, input[type="checkbox"]:checked + label span { position: relative; cursor: pointer; } input[type="checkbox"]:not(:checked) + label span:before, input[type="checkbox"]:checked + label span:before { content: ''; position: absolute; right: 10px; width: 15px; height: 15px; border: 1px solid #a5a5b1; background: none; border-radius: 3px; -webkit-box-shadow: inset 0px 0px 8px 0px rgba(50, 50, 50, 0.13); -moz-box-shadow: inset 0px 0px 8px 0px rgba(50, 50, 50, 0.13); box-shadow: inset 0px 0px 8px 0px rgba(50, 50, 50, 0.13); margin: 0; padding: 0; } input[type="checkbox"]:not(:checked) + label span:after, input[type="checkbox"]:checked + label span:after { content: '★'; position: absolute; width: 15px; height: 15px; top: -1px; right: 10px; font-size: 1.2em; border-radius: 3px; color: #ffc20e; transition: .5s; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); margin: 0; padding: 0; font-family: arial, sans-serif; border: 1px solid #000000; text-align: center; vertical-align: middle; } input[type="checkbox"]:not(:checked) + label span:after { opacity: 0; transform: scale(0); } input[type="checkbox"]:checked + label span:after { opacity: 1; transform: scale(1); } input[type="checkbox"]:disabled:not(:checked) + label span:before, input[type="checkbox"]:disabled:checked + label span:before { box-shadow: none; border-color: #bbb; background-color: #ddd; } input[type="checkbox"]:disabled:checked + label span:after { color: #999; } input[type="checkbox"]:disabled + label span { color: #aaa; } /* accessibility */ input[type="checkbox"]:checked:focus + label span:before, input[type="checkbox"]:not(:checked):focus + label span:before { border: 1px dotted blue; }
if click boxes checked state , in different browsers you'll notice positioning off , size of star different...
edit: know example doesn't show them align start off - interested in why they're positioned differently
try adding line-height
corresponding element height :after
elements used display star,
input[type="checkbox"]:not(:checked) + label span:after, input[type="checkbox"]:checked + label span:after { /* … */ top: 0; /* modified */ line-height: 13px; }
with that, looks ok me in firefox , opera. http://jsfiddle.net/mbwm3/1/
Comments
Post a Comment