ਕਿਵੇਂ ਬਣਾਓ: ਪਰਸੋਨਲਾਈਜ਼ਡ ਚੈਕ ਬਕਸ
CSS ਨਾਲ ਪਰਸੋਨਲਾਈਜ਼ਡ ਚੈਕ ਬਕਸ ਅਤੇ ਰੇਡੀਓ ਬਟਨ ਕਿਵੇਂ ਵਰਤਣਾ ਹੈ ਸਿੱਖੋ。
ਮੂਲਤਵੀ:
OneTwo
One
Two
ਪਰਸੋਨਲਾਈਜ਼ਡ ਚੈਕ ਬਕਸ:
ਪਰਸੋਨਲਾਈਜ਼ਡ ਰੇਡੀਓ ਬਟਨ:
ਪਰਸੋਨਲਾਈਜ਼ਡ ਚੈਕ ਬਕਸ ਕਿਵੇਂ ਬਣਾਓ
ਕਦਮ 1 - ਐੱਚਟੀਐੱਮਐੱਲ ਜੋੜੋ:
<label class="container">One <input type="checkbox" checked="checked"> <span class="checkmark"></span> </label> <label class="container">Two <input type="checkbox"> <span class="checkmark"></span> </label> <label class="container">Three <input type="checkbox"> <span class="checkmark"></span> </label> <label class="container">Four <input type="checkbox"> <span class="checkmark"></span> </label>
ਕਦਮ 2 - ਸੀਐੱਸਐੱਸ ਜੋੜੋ:
/* 自定义标签(容器) */ .container { display: block; position: relative; padding-left: 35px; margin-bottom: 12px; cursor: pointer; font-size: 22px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } /* ਬਰਾਉਜ਼ਰ ਦੇ ਡਿਫਾਲਟ ਚੈਕ ਬਕਸ ਨੂੰ ਛੁਪਾਓ */ .container input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; } /* ਪਰਸੋਨਲਾਈਜ਼ਡ ਚੈਕ ਬਕਸ ਬਣਾਓ */ .checkmark { position: absolute; top: 0; left: 0; height: 25px; width: 25px; background-color: #eee; } /* 鼠标悬停时,添加灰色背景颜色 */ .container:hover input ~ .checkmark { background-color: #ccc; } /* ਚੈਕ ਬਕਸ ਚੋਣ ਕਰਨ ਉੱਤੇ ਨੀਲੇ ਪਿੱਨ ਜੋੜੋ */ .container input:checked ~ .checkmark { background-color: #2196F3; } /* ਚੈਕ ਟੈਗ/ਇੰਡੀਕੇਟਰ ਬਣਾਓ (ਚੋਣ ਨਾ ਹੋਣ ਉੱਤੇ ਛੁਪਾਓ) */ .checkmark:after { content: ""; position: absolute; display: none; } /* ਚੋਣਨ ਹੋਣ ਉੱਤੇ ਚੈਕ ਟੈਗ ਦਿਖਾਓ */ .container input:checked ~ .checkmark:after { display: block; } /* ਸੈਕਸ਼ਨ ਟੈਗ ਸਟਾਈਲ ਸੈਟ ਕਰੋ */ .container .checkmark:after { left: 9px; top: 5px; width: 5px; height: 10px; border: solid white; border-width: 0 3px 3px 0; -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); }
ਕਿਵੇਂ ਆਪਣੀਆਂ ਪਸੰਦੀਦਾ ਚੋਣਾਂ ਬਣਾਓ
ਇੱਕੱਪ੍ਰੈਕਸ਼ਨ
/* 自定义标签(容器) */ .container { display: block; position: relative; padding-left: 35px; margin-bottom: 12px; cursor: pointer; font-size: 22px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } /* 隐藏浏览器的默认单选按钮 */ .container input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; } /* 创建自定义单选按钮 */ .checkmark { position: absolute; top: 0; left: 0; height: 25px; width: 25px; background-color: #eee; border-radius: 50%; } /* 鼠标悬停时,添加灰色背景颜色 */ .container:hover input ~ .checkmark { background-color: #ccc; } /* 当单选按钮被选中时,添加蓝色背景 */ .container input:checked ~ .checkmark { background-color: #2196F3; } /* 创建指示器(点/圆 - 未选中时隐藏) */ .checkmark:after { content: ""; position: absolute; display: none; } /* 选中时显示指示器(点/圆) */ .container input:checked ~ .checkmark:after { display: block; } /* 设置指示器样式(点/圆) */ .container .checkmark:after { top: 9px; left: 9px; width: 8px; height: 8px; border-radius: 50%; background: white; }