admin管理员组文章数量:1400080
I am making a toggle button that is a ClipPath hexagon. I wanna make it so in its Checked state it puts in another Clip Path Hexagon in the middle. With this behavior it simply replaces the background color.
.inp_toggle {
height: 2em;
width: 2.25em;
clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
background: #3c3c3c;
margin-bottom: 1em;
}
.inp_toggle.checked {
background: #a92800;
}
I am making a toggle button that is a ClipPath hexagon. I wanna make it so in its Checked state it puts in another Clip Path Hexagon in the middle. With this behavior it simply replaces the background color.
.inp_toggle {
height: 2em;
width: 2.25em;
clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
background: #3c3c3c;
margin-bottom: 1em;
}
.inp_toggle.checked {
background: #a92800;
}
Share
Improve this question
asked Mar 25 at 8:13
user30021668user30021668
1
- Please provide a proper minimal reproducible example when asking this kind of question, not just snippets that lack context. – C3roe Commented Mar 25 at 8:22
1 Answer
Reset to default 1Use a pseudo elemet (:before
) to place a smaller hexagon in the middle.
Click the hexagon to see the example:
.inp_toggle, .inp_toggle::before {
clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
.inp_toggle {
display: flex;
align-items: center;
justify-content: center;
height: 2em;
width: 2.25em;
background: #3c3c3c;
margin-bottom: 1em;
}
.inp_toggle:has(input:checked)::before {
width: 50%;
height: 50%;
background: #a92800;
content: '';
}
<label class="inp_toggle">
<input type="checkbox" hidden>
</label>
本文标签: cssFacing problem while making a toggle with Clip PathStack Overflow
版权声明:本文标题:css - Facing problem while making a toggle with Clip Path - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744211164a2595423.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论