我试图使用以下样式的复选框:
<输入类型=“checkbox”样式=“border:2px点数:00f;显示:block;背景:ff0000;”/>
但是没有应用样式。复选框仍然显示其默认样式。我如何给它指定的样式?
我试图使用以下样式的复选框:
<输入类型=“checkbox”样式=“border:2px点数:00f;显示:block;背景:ff0000;”/>
但是没有应用样式。复选框仍然显示其默认样式。我如何给它指定的样式?
当前回答
你可以简单地使用appearance:在现代浏览器中没有,这样就没有默认样式,所有的样式都被正确应用:
input[type=checkbox] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
display: inline-block;
width: 2em;
height: 2em;
border: 1px solid gray;
outline: none;
vertical-align: middle;
}
input[type=checkbox]:checked {
background-color: blue;
}
其他回答
呵!所有这些变通方法让我得出结论,如果你想要设置HTML复选框的样式,那么它就很糟糕。
作为一个警告,这不是一个CSS实现。我只是想分享一下我想出的解决办法以防其他人会觉得有用。
我使用HTML5 canvas元素。
这样做的好处是您不必使用外部图像,并且可能节省一些带宽。
缺点是,如果浏览器由于某种原因不能正确地呈现它,那么就没有退路了。不过,在2017年,这是否仍然是一个值得商榷的问题。
更新
我发现旧的代码很难看,所以我决定重写一遍。
Object.prototype.create = function(args){
var retobj = Object.create(this);
retobj.constructor(args || null);
return retobj;
}
var Checkbox = Object.seal({
width: 0,
height: 0,
state: 0,
document: null,
parent: null,
canvas: null,
ctx: null,
/*
* args:
* name default desc.
*
* width 15 width
* height 15 height
* document window.document explicit document reference
* target this.document.body target element to insert checkbox into
*/
constructor: function(args){
if(args === null)
args = {};
this.width = args.width || 15;
this.height = args.height || 15;
this.document = args.document || window.document;
this.parent = args.target || this.document.body;
this.canvas = this.document.createElement("canvas");
this.ctx = this.canvas.getContext('2d');
this.canvas.width = this.width;
this.canvas.height = this.height;
this.canvas.addEventListener("click", this.ev_click(this), false);
this.parent.appendChild(this.canvas);
this.draw();
},
ev_click: function(self){
return function(unused){
self.state = !self.state;
self.draw();
}
},
draw_rect: function(color, offset){
this.ctx.fillStyle = color;
this.ctx.fillRect(offset, offset,
this.width - offset * 2, this.height - offset * 2);
},
draw: function(){
this.draw_rect("#CCCCCC", 0);
this.draw_rect("#FFFFFF", 1);
if(this.is_checked())
this.draw_rect("#000000", 2);
},
is_checked: function(){
return !!this.state;
}
});
这里是一个工作演示。
新版本使用原型和差分继承来创建一个用于创建复选框的高效系统。创建复选框:
var my_checkbox = Checkbox.create();
这将立即将复选框添加到DOM并连接事件。查询复选框是否勾选。
my_checkbox.is_checked(); // True if checked, else false
同样需要注意的是,我去掉了循环。
更新2
在上次更新中我忽略了一点,那就是使用canvas比仅仅创建一个你想要的复选框有更多的优势。如果您愿意,还可以创建多状态复选框。
Object.prototype.create = function(args){
var retobj = Object.create(this);
retobj.constructor(args || null);
return retobj;
}
Object.prototype.extend = function(newobj){
var oldobj = Object.create(this);
for(prop in newobj)
oldobj[prop] = newobj[prop];
return Object.seal(oldobj);
}
var Checkbox = Object.seal({
width: 0,
height: 0,
state: 0,
document: null,
parent: null,
canvas: null,
ctx: null,
/*
* args:
* name default desc.
*
* width 15 width
* height 15 height
* document window.document explicit document reference
* target this.document.body target element to insert checkbox into
*/
constructor: function(args){
if(args === null)
args = {};
this.width = args.width || 15;
this.height = args.height || 15;
this.document = args.document || window.document;
this.parent = args.target || this.document.body;
this.canvas = this.document.createElement("canvas");
this.ctx = this.canvas.getContext('2d');
this.canvas.width = this.width;
this.canvas.height = this.height;
this.canvas.addEventListener("click", this.ev_click(this), false);
this.parent.appendChild(this.canvas);
this.draw();
},
ev_click: function(self){
return function(unused){
self.state = !self.state;
self.draw();
}
},
draw_rect: function(color, offsetx, offsety){
this.ctx.fillStyle = color;
this.ctx.fillRect(offsetx, offsety,
this.width - offsetx * 2, this.height - offsety * 2);
},
draw: function(){
this.draw_rect("#CCCCCC", 0, 0);
this.draw_rect("#FFFFFF", 1, 1);
this.draw_state();
},
draw_state: function(){
if(this.is_checked())
this.draw_rect("#000000", 2, 2);
},
is_checked: function(){
return this.state == 1;
}
});
var Checkbox3 = Checkbox.extend({
ev_click: function(self){
return function(unused){
self.state = (self.state + 1) % 3;
self.draw();
}
},
draw_state: function(){
if(this.is_checked())
this.draw_rect("#000000", 2, 2);
if(this.is_partial())
this.draw_rect("#000000", 2, (this.height - 2) / 2);
},
is_partial: function(){
return this.state == 2;
}
});
我稍微修改了上一个代码片段中使用的复选框,使其更通用,从而可以使用具有3个状态的复选框“扩展”它。这是一个演示。正如您所看到的,它已经拥有了比内置复选框更多的功能。
在JavaScript和CSS之间进行选择时需要考虑的问题。
旧的、设计糟糕的代码
演示工作
首先,设置一个画布
var canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d'),
checked = 0; // The state of the checkbox
canvas.width = canvas.height = 15; // Set the width and height of the canvas
document.body.appendChild(canvas);
document.body.appendChild(document.createTextNode(' Togglable Option'));
接下来,设计一种让画布自我更新的方法。
(function loop(){
// Draws a border
ctx.fillStyle = '#ccc';
ctx.fillRect(0,0,15,15);
ctx.fillStyle = '#fff';
ctx.fillRect(1, 1, 13, 13);
// Fills in canvas if checked
if(checked){
ctx.fillStyle = '#000';
ctx.fillRect(2, 2, 11, 11);
}
setTimeout(loop, 1000/10); // Refresh 10 times per second
})();
最后一部分是使其具有互动性。幸运的是,这很简单:
canvas.onclick = function(){
checked = !checked;
}
这就是你在IE中可能会遇到的问题,因为JavaScript中奇怪的事件处理模型。
我希望这能帮助到一些人;它绝对符合我的需要。
你可以使用label元素设置复选框的样式,示例如下:
.checkbox > input[type=checkbox] { visibility: hidden; } .checkbox { position: relative; display: block; width: 80px; height: 26px; margin: 0 auto; background: #FFF; border: 1px solid #2E2E2E; border-radius: 2px; -webkit-border-radius: 2px; -moz-border-radius: 2px; } .checkbox:after { position: absolute; display: inline; right: 10px; content: 'no'; color: #E53935; font: 12px/26px Arial, sans-serif; font-weight: bold; text-transform: capitalize; z-index: 0; } .checkbox:before { position: absolute; display: inline; left: 10px; content: 'yes'; color: #43A047; font: 12px/26px Arial, sans-serif; font-weight: bold; text-transform: capitalize; z-index: 0; } .checkbox label { position: absolute; display: block; top: 3px; left: 3px; width: 34px; height: 20px; background: #2E2E2E; cursor: pointer; transition: all 0.5s linear; -webkit-transition: all 0.5s linear; -moz-transition: all 0.5s linear; border-radius: 2px; -webkit-border-radius: 2px; -moz-border-radius: 2px; z-index: 1; } .checkbox input[type=checkbox]:checked + label { left: 43px; } <div class="checkbox"> <input id="checkbox1" type="checkbox" value="1" /> <label for="checkbox1"></label> </div>
上面的代码还有一个FIDDLE。注意,有些CSS在旧版本的浏览器中不起作用,但我相信有一些奇特的JavaScript示例!
通过使用:after和:before伪类附带的新功能,可以实现相当酷的自定义复选框效果。这样做的好处是:您不需要向DOM添加任何其他内容,只需添加标准复选框即可。
注意,这只适用于兼容的浏览器。我相信这与一些浏览器不允许你在输入元素上设置:after和:before有关。不幸的是,目前只支持WebKit浏览器。Firefox + Internet Explorer仍然允许复选框发挥作用,只是没有样式,这在未来有望改变(代码不使用供应商前缀)。
这是一个WebKit浏览器解决方案(Chrome, Safari,移动浏览器)
参见小提琴
$(function() { $('input').change(function() { $('div').html(Math.random()); }); }); /* Main Classes */ .myinput[type="checkbox"]:before { position: relative; display: block; width: 11px; height: 11px; border: 1px solid #808080; content: ""; background: #FFF; } .myinput[type="checkbox"]:after { position: relative; display: block; left: 2px; top: -11px; width: 7px; height: 7px; border-width: 1px; border-style: solid; border-color: #B3B3B3 #dcddde #dcddde #B3B3B3; content: ""; background-image: linear-gradient(135deg, #B1B6BE 0%, #FFF 100%); background-repeat: no-repeat; background-position: center; } .myinput[type="checkbox"]:checked:after { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAQAAABuW59YAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAB2SURBVHjaAGkAlv8A3QDyAP0A/QD+Dam3W+kCAAD8APYAAgTVZaZCGwwA5wr0AvcA+Dh+7UX/x24AqK3Wg/8nt6w4/5q71wAAVP9g/7rTXf9n/+9N+AAAtpJa/zf/S//DhP8H/wAA4gzWj2P4lsf0JP0A/wADAHB0Ngka6UmKAAAAAElFTkSuQmCC'), linear-gradient(135deg, #B1B6BE 0%, #FFF 100%); } .myinput[type="checkbox"]:disabled:after { -webkit-filter: opacity(0.4); } .myinput[type="checkbox"]:not(:disabled):checked:hover:after { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAQAAABuW59YAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAB2SURBVHjaAGkAlv8A3QDyAP0A/QD+Dam3W+kCAAD8APYAAgTVZaZCGwwA5wr0AvcA+Dh+7UX/x24AqK3Wg/8nt6w4/5q71wAAVP9g/7rTXf9n/+9N+AAAtpJa/zf/S//DhP8H/wAA4gzWj2P4lsf0JP0A/wADAHB0Ngka6UmKAAAAAElFTkSuQmCC'), linear-gradient(135deg, #8BB0C2 0%, #FFF 100%); } .myinput[type="checkbox"]:not(:disabled):hover:after { background-image: linear-gradient(135deg, #8BB0C2 0%, #FFF 100%); border-color: #85A9BB #92C2DA #92C2DA #85A9BB; } .myinput[type="checkbox"]:not(:disabled):hover:before { border-color: #3D7591; } /* Large checkboxes */ .myinput.large { height: 22px; width: 22px; } .myinput.large[type="checkbox"]:before { width: 20px; height: 20px; } .myinput.large[type="checkbox"]:after { top: -20px; width: 16px; height: 16px; } /* Custom checkbox */ .myinput.large.custom[type="checkbox"]:checked:after { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGHRFWHRBdXRob3IAbWluZWNyYWZ0aW5mby5jb23fZidLAAAAk0lEQVQ4y2P4//8/AyUYwcAD+OzN/oMwshjRBoA0Gr8+DcbIhhBlAEyz+qZZ/7WPryHNAGTNMOxpJvo/w0/uP0kGgGwGaZbrKgfTGnLc/0nyAgiDbEY2BCRGdCDCnA2yGeYVog0Aae5MV4c7Gzk6CRqAbDM2w/EaQEgzXgPQnU2SAcTYjNMAYm3GaQCxNuM0gFwMAPUKd8XyBVDcAAAAAElFTkSuQmCC'), linear-gradient(135deg, #B1B6BE 0%, #FFF 100%); } .myinput.large.custom[type="checkbox"]:not(:disabled):checked:hover:after { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGHRFWHRBdXRob3IAbWluZWNyYWZ0aW5mby5jb23fZidLAAAAk0lEQVQ4y2P4//8/AyUYwcAD+OzN/oMwshjRBoA0Gr8+DcbIhhBlAEyz+qZZ/7WPryHNAGTNMOxpJvo/w0/uP0kGgGwGaZbrKgfTGnLc/0nyAgiDbEY2BCRGdCDCnA2yGeYVog0Aae5MV4c7Gzk6CRqAbDM2w/EaQEgzXgPQnU2SAcTYjNMAYm3GaQCxNuM0gFwMAPUKd8XyBVDcAAAAAElFTkSuQmCC'), linear-gradient(135deg, #8BB0C2 0%, #FFF 100%); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table style="width:100%"> <tr> <td>Normal:</td> <td><input type="checkbox" /></td> <td><input type="checkbox" checked="checked" /></td> <td><input type="checkbox" disabled="disabled" /></td> <td><input type="checkbox" disabled="disabled" checked="checked" /></td> </tr> <tr> <td>Small:</td> <td><input type="checkbox" class="myinput" /></td> <td><input type="checkbox" checked="checked" class="myinput" /></td> <td><input type="checkbox" disabled="disabled" class="myinput" /></td> <td><input type="checkbox" disabled="disabled" checked="checked" class="myinput" /></td> </tr> <tr> <td>Large:</td> <td><input type="checkbox" class="myinput large" /></td> <td><input type="checkbox" checked="checked" class="myinput large" /></td> <td><input type="checkbox" disabled="disabled" class="myinput large" /></td> <td><input type="checkbox" disabled="disabled" checked="checked" class="myinput large" /></td> </tr> <tr> <td>Custom icon:</td> <td><input type="checkbox" class="myinput large custom" /></td> <td><input type="checkbox" checked="checked" class="myinput large custom" /></td> <td><input type="checkbox" disabled="disabled" class="myinput large custom" /></td> <td><input type="checkbox" disabled="disabled" checked="checked" class="myinput large custom" /></td> </tr> </table>
奖金Webkit风格的翻转开关小提琴
$(function() { var f = function() { $(this).next().text($(this).is(':checked') ? ':checked' : ':not(:checked)'); }; $('input').change(f).trigger('change'); }); body { font-family: arial; } .flipswitch { position: relative; background: white; width: 120px; height: 40px; -webkit-appearance: initial; border-radius: 3px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); outline: none; font-size: 14px; font-family: Trebuchet, Arial, sans-serif; font-weight: bold; cursor: pointer; border: 1px solid #ddd; } .flipswitch:after { position: absolute; top: 5%; display: block; line-height: 32px; width: 45%; height: 90%; background: #fff; box-sizing: border-box; text-align: center; transition: all 0.3s ease-in 0s; color: black; border: #888 1px solid; border-radius: 3px; } .flipswitch:after { left: 2%; content: "OFF"; } .flipswitch:checked:after { left: 53%; content: "ON"; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <h2>Webkit friendly mobile-style checkbox/flipswitch</h2> <input type="checkbox" class="flipswitch" /> <span></span> <br> <input type="checkbox" checked="checked" class="flipswitch" /> <span></span>
我更喜欢使用图标字体(如fontawesme),因为它很容易用CSS修改它们的颜色,而且它们在高像素密度的设备上缩放得非常好。这里是另一个纯CSS变体,使用类似于上面的技术。
(下面是一个静态图像,这样你可以可视化结果;请参阅JSFiddle的交互式版本。)
与其他解决方案一样,它使用label元素。相邻的span保存复选框字符。
span.bigcheck-target { font-family: FontAwesome; /* Use an icon font for the checkbox */ } input[type='checkbox'].bigcheck { position: relative; left: -999em; /* Hide the real checkbox */ } input[type='checkbox'].bigcheck + span.bigcheck-target:after { content: "\f096"; /* In fontawesome, is an open square (fa-square-o) */ } input[type='checkbox'].bigcheck:checked + span.bigcheck-target:after { content: "\f046"; /* fontawesome checked box (fa-check-square-o) */ } /* ==== Optional - colors and padding to make it look nice === */ body { background-color: #2C3E50; color: #D35400; font-family: sans-serif; font-weight: 500; font-size: 4em; /* Set this to whatever size you want */ } span.bigcheck { display: block; padding: 0.5em; } <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" /> <span class="bigcheck"> <label class="bigcheck"> Cheese <input type="checkbox" class="bigcheck" name="cheese" value="yes" /> <span class="bigcheck-target"></span> </label> </span>
这是它的JSFiddle。
下面是一个带有主题支持的示例。这是一种现代的CSS转换方法。绝对不需要JavaScript。
我得到了下面的代码链接在这条评论;在一个相关问题上。
编辑:我添加了单选按钮,maxshuty建议。
const selector = '.grid-container > .grid-row > .grid-col[data-theme="retro"]'; const main = () => { new CheckboxStyler().run(selector); new RadioStyler().run(selector); }; /* * This is only used to add the wrapper class and checkmark span to an existing DOM, * to make this CSS work. */ class AbstractInputStyler { constructor(options) { this.opts = options; } run(parentSelector) { let wrapperClass = this.opts.wrapperClass; let parent = document.querySelector(parentSelector) || document.getElementsByTagName('body')[0]; let labels = parent.querySelectorAll('label'); if (labels.length) labels.forEach(label => { if (label.querySelector(`input[type="${this.opts._inputType}"]`)) { if (!label.classList.contains(wrapperClass)) { label.classList.add(wrapperClass); label.appendChild(this.__createDefaultNode()); } } }); return this; } /* @protected */ __createDefaultNode() { let checkmark = document.createElement('span'); checkmark.className = this.opts._activeClass; return checkmark; } } class CheckboxStyler extends AbstractInputStyler { constructor(options) { super(Object.assign({ _inputType: 'checkbox', _activeClass: 'checkmark' }, CheckboxStyler.defaultOptions, options)); } } CheckboxStyler.defaultOptions = { wrapperClass: 'checkbox-wrapper' }; class RadioStyler extends AbstractInputStyler { constructor(options) { super(Object.assign({ _inputType: 'radio', _activeClass: 'pip' }, RadioStyler.defaultOptions, options)); } } RadioStyler.defaultOptions = { wrapperClass: 'radio-wrapper' }; main(); /* Theming */ :root { --background-color: #FFF; --font-color: #000; --checkbox-default-background: #EEE; --checkbox-hover-background: #CCC; --checkbox-disabled-background: #AAA; --checkbox-selected-background: #1A74BA; --checkbox-selected-disabled-background: #6694B7; --checkbox-checkmark-color: #FFF; --checkbox-checkmark-disabled-color: #DDD; } [data-theme="dark"] { --background-color: #111; --font-color: #EEE; --checkbox-default-background: #222; --checkbox-hover-background: #444; --checkbox-disabled-background: #555; --checkbox-selected-background: #2196F3; --checkbox-selected-disabled-background: #125487; --checkbox-checkmark-color: #EEE; --checkbox-checkmark-disabled-color: #999; } [data-theme="retro"] { --background-color: #FFA; --font-color: #000; --checkbox-default-background: #EEE; --checkbox-hover-background: #FFF; --checkbox-disabled-background: #BBB; --checkbox-selected-background: #EEE; --checkbox-selected-disabled-background: #BBB; --checkbox-checkmark-color: #F44; --checkbox-checkmark-disabled-color: #D00; } /* General styles */ html { width: 100%; height: 100%; } body { /*background: var(--background-color); -- For demo, moved to column. */ /*color: var(--font-color); -- For demo, moved to column. */ background: #777; width: calc(100% - 0.5em); height: calc(100% - 0.5em); padding: 0.25em; } h1 { font-size: 1.33em !important; } h2 { font-size: 1.15em !important; margin-top: 1em; } /* Grid style - using flex */ .grid-container { display: flex; height: 100%; flex-direction: column; flex: 1; } .grid-row { display: flex; flex-direction: row; flex: 1; margin: 0.25em 0; } .grid-col { display: flex; flex-direction: column; height: 100%; padding: 0 1em; flex: 1; margin: 0 0.25em; /* If not demo, remove and uncomment the body color rules */ background: var(--background-color); color: var(--font-color); } .grid-cell { width: 100%; height: 100%; } /* The checkbox wrapper */ .checkbox-wrapper, .radio-wrapper { display: block; position: relative; padding-left: 1.5em; margin-bottom: 0.5em; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } /* Hide the browser's default checkbox and radio buttons */ .checkbox-wrapper input[type="checkbox"] { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; } .radio-wrapper input[type="radio"] { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; } /* Create a custom checkbox */ .checkbox-wrapper .checkmark { position: absolute; top: 0; left: 0; height: 1em; width: 1em; background-color: var(--checkbox-default-background); transition: all 0.2s ease-in; } .radio-wrapper .pip { position: absolute; top: 0; left: 0; height: 1em; width: 1em; border-radius: 50%; background-color: var(--checkbox-default-background); transition: all 0.2s ease-in; } /* Disabled style */ .checkbox-wrapper input[type="checkbox"]:disabled~.checkmark, .radio-wrapper input[type="radio"]:disabled~.pip { cursor: not-allowed; background-color: var(--checkbox-disabled-background); color: var(--checkbox-checkmark-disabled-color); } .checkbox-wrapper input[type="checkbox"]:disabled~.checkmark:after, .radio-wrapper input[type="radio"]:disabled~.pip:after { color: var(--checkbox-checkmark-disabled-color); } .checkbox-wrapper input[type="checkbox"]:disabled:checked~.checkmark, .radio-wrapper input[type="radio"]:disabled:checked~.pip { background-color: var(--checkbox-selected-disabled-background); } /* On mouse-over, add a grey background color */ .checkbox-wrapper:hover input[type="checkbox"]:not(:disabled):not(:checked)~.checkmark, .radio-wrapper:hover input[type="radio"]:not(:disabled):not(:checked)~.pip { background-color: var(--checkbox-hover-background); } /* When the checkbox is checked, add a blue background */ .checkbox-wrapper input[type="checkbox"]:checked~.checkmark, .radio-wrapper input[type="radio"]:checked~.pip { background-color: var(--checkbox-selected-background); } /* Create the checkmark/indicator (hidden when not checked) */ .checkbox-wrapper .checkmark:after { display: none; width: 100%; position: absolute; text-align: center; content: "\2713"; color: var(--checkbox-checkmark-color); line-height: 1.1em; } .radio-wrapper .pip:after { display: none; width: 100%; position: absolute; text-align: center; content: "\2022"; color: var(--checkbox-checkmark-color); font-size: 1.5em; top: -0.2em; } /* Show the checkmark when checked */ .checkbox-wrapper input[type="checkbox"]:checked~.checkmark:after { display: block; line-height: 1.1em; } .radio-wrapper input[type="radio"]:checked~.pip:after { display: block; line-height: 1.1em; } <link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet" /> <div class="grid-container"> <div class="grid-row"> <div class="grid-col"> <div class="grid-cell"> <h1>Pure CSS</h1> <h2>Checkbox</h2> <label class="checkbox-wrapper">One <input type="checkbox" checked="checked"> <span class="checkmark"></span> </label> <label class="checkbox-wrapper">Two <input type="checkbox"> <span class="checkmark"></span> </label> <label class="checkbox-wrapper">Three <input type="checkbox" checked disabled> <span class="checkmark"></span> </label> <label class="checkbox-wrapper">Four <input type="checkbox" disabled> <span class="checkmark"></span> </label> <h2>Radio</h2> <label class="radio-wrapper">One <input type="radio" name="group-x"> <span class="pip"></span> </label> <label class="radio-wrapper">Two <input type="radio" name="group-x"> <span class="pip"></span> </label> <label class="radio-wrapper">Three <input type="radio" name="group-x" checked disabled> <span class="pip"></span> </label> <label class="radio-wrapper">Four <input type="radio" name="group-x" disabled> <span class="pip"></span> </label> </div> </div> <div class="grid-col" data-theme="dark"> <div class="grid-cell"> <h1>Pure CSS</h1> <h2>Checkbox</h2> <label class="checkbox-wrapper">One <input type="checkbox" checked="checked"> <span class="checkmark"></span> </label> <label class="checkbox-wrapper">Two <input type="checkbox"> <span class="checkmark"></span> </label> <label class="checkbox-wrapper">Three <input type="checkbox" checked disabled> <span class="checkmark"></span> </label> <label class="checkbox-wrapper">Four <input type="checkbox" disabled> <span class="checkmark"></span> </label> <h2>Radio</h2> <label class="radio-wrapper">One <input type="radio" name="group-y"> <span class="pip"></span> </label> <label class="radio-wrapper">Two <input type="radio" name="group-y"> <span class="pip"></span> </label> <label class="radio-wrapper">Three <input type="radio" name="group-y" checked disabled> <span class="pip"></span> </label> <label class="radio-wrapper">Four <input type="radio" name="group-y" disabled> <span class="pip"></span> </label> </div> </div> <div class="grid-col" data-theme="retro"> <div class="grid-cell"> <h1>JS + CSS</h1> <h2>Checkbox</h2> <label>One <input type="checkbox" checked="checked"></label> <label>Two <input type="checkbox"></label> <label>Three <input type="checkbox" checked disabled></label> <label>Four <input type="checkbox" disabled></label> <h2>Radio</h2> <label>One <input type="radio" name="group-z" checked="checked"></label> <label>Two <input type="radio" name="group-z"></label> <label>Three <input type="radio" name="group-z" checked disabled></label> <label>Four <input type="radio" name="group-z" disabled></label> </div> </div> </div> </div>