[英]css checkbox checked material design overlay
I'm trying to do some fancy material design like checkboxes but I got stuck at applying an overlay when the checkboxes are checked. 我试图做一些奇特的材料设计,例如复选框,但是当复选框被选中时,我被困在应用覆盖层上。 Here is an example of what I have done so far: http://codepen.io/stefancenusa/pen/rVwEBB 这是到目前为止我所做的一个示例: http : //codepen.io/stefancenusa/pen/rVwEBB
input[type="checkbox"]:checked + label {
/*what should i write here?*/
}
What I intend to do: after a checkbox is clicked, I'd like a white overlay with a tick in the center to appear over the colored circle. 我打算做什么:单击复选框后,我希望白色的叠加层中间有一个勾号出现在彩色圆圈上。
Is this possible? 这可能吗? How can I achieve that? 我该如何实现?
Thank you! 谢谢!
I gave it a shot. 我试了一下 Hope it helps. 希望能帮助到你。
input[type="checkbox"]:checked + label:before {
content: '✓';
font-size: 2em;
line-height: 53px;
text-align: center;
display: block;
position: absolute;
width: 53px;
height: 53px;
top: 0;
left: 0;
color: #fff;
}
Update: Tweaked it a little.. 更新:稍作调整。
You can set a cool icon to replace the text, by some other font or by background-image
. 您可以设置一个很酷的图标,以其他字体或background-image
替换文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.