2012-12-24 22 views
5

में काम नहीं करता मैं इस सीएसएस के साथ एक कस्टम चेकबॉक्स बना रहा हूं:: जाँच की छद्म वर्ग क्रोम

<div class="editor-label"> 
    <input class="check-box" data-val="true" id="Persistent" name="Persistent" type="checkbox" value="true" /> 
    <input name="Persistent" type="hidden" value="false" /> 
    <label for="Persistent">Keep me!</label> 
</div> 

input तत्वों द्वारा बनाई गई हैं:

input[type="checkbox"] { 
    background: transparent; 
    border: inherit; 
    width: auto; 
} 
input[type=checkbox] { 
    display: none; 
} 
input[type=checkbox] + input + label, 
input[type=checkbox] + label, 
div:not(#foo) > input[type=checkbox] + label, 
div:not(#foo) > input[type=checkbox] + input + label { 
    cursor: pointer; 
    height: 16px; 
    padding: 0 0 0 18px; 
    background: transparent url(/assets/images/checkbox-unchecked.png) no-repeat left 3px; 
} 
input[type=checkbox]:checked + input + label, 
input[type=checkbox]:checked + label, 
div:not(#foo) > input[type=checkbox]:checked + label, 
div:not(#foo) > input[type=checkbox]:checked + input + label { 
    background: transparent url(/assets/images/checkbox-checked.png) no-repeat left 3px; 
} 
.ie6 input[type=checkbox], 
.ie7 input[type=checkbox], 
.ie8 input[type=checkbox] { 
    display: inline-block; 
    *display: inline; 
    *zoom: 1; 
} 

और यहाँ मेरी html मार्कअप है @Html.EditorFor(model => model.BooleanProp)Razor में। यह कोड क्रोम को छोड़कर ठीक काम करता है। असल में क्रोम में, जब हम चेकबॉक्स पर क्लिक करते हैं, तो हम प्रभाव देखेंगे (प्रभाव से मेरा मतलब है कि लेबल के लिए पृष्ठभूमि-छवि को बदलना जो चेकबॉक्स चेक किया गया है या नहीं) हम सबमिट बोत पर क्लिक करने के बाद। कोई विचार कृपया?

अद्यतन

यहाँ एक demo

+0

अगर आप किसी [सरल डेमो] है (http://jsfiddle.net/) हम देख सकते हैं कि आपकी समस्या reproduces? –

उत्तर

6

मुझे विश्वास है कि वेबकिट श्रृंखलित + चयनकर्ताओं कि ... ~ label के लिए छद्म चयनकर्ताओं

स्वैप श्रृंखलित ... + input + label चयनकर्ताओं का पालन के साथ मुद्दों है।

उदाहरण के लिए:

div:not(#foo) > input[type=checkbox] ~ label 
+1

आप बिल्कुल सही हैं। यह काम करता हैं। आपका बहुत बहुत धन्यवाद। –

+0

मेरे लिए काम नहीं किया !! – Mak

+0

@ मैक जो वास्तव में एक उपयोगी टिप्पणी नहीं है। क्या आप एक [JSFiddle] (http://jsfiddle.net/) प्रदान कर सकते हैं जो यह काम नहीं कर रहा है –

संबंधित मुद्दे