带有CSS的复选框波纹效果
Posted
技术标签:
【中文标题】带有CSS的复选框波纹效果【英文标题】:checkbox ripple effects with css 【发布时间】:2020-12-27 11:51:17 【问题描述】:我正在尝试为复选框实现波纹效果,但它没有准确显示,波纹效果宽度变得太大,下面是我尝试过的代码。我需要一个带有浅色背景的小宽度波纹效果,我想我错过了一些样式。谁能帮我解决这个问题,在此先感谢
.checkbox label
display: inline-block;
vertical-align: middle;
position: relative;
padding-left: 5px;
.checkbox label::before
content: "";
display: inline-block;
position: absolute;
width: 18px;
height: 18px;
left: 2px;
top: 0px;
margin-left: -20px;
border: 1px solid #ccc;
border-radius: 2px;
background-color: #fff;
-webkit-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
-o-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
.checkbox label::after
display: inline-block;
position: absolute;
width: 16px;
height: 16px;
left: 1px;
top: 1px;
font-weight: 100;
margin-left: -18px;
padding-left: 3px;
padding-top: 1px;
font-size: 11px;
color: #555;
.cbox-table label::after,
.cbox-table label::before
margin-left: 0px;
.checkbox input[type="checkbox"],
.checkbox input[type="radio"]
opacity: 0;
z-index: 1;
cursor: pointer;
.checkbox input[type="checkbox"]:indeterminate + label::after,
.checkbox input[type="radio"]:indeterminate + label::after
display: block;
content: "";
width: 10px;
height: 3px;
background-color: #555;
border-radius: 2px;
margin-left: -16.5px;
margin-top: 7px;
.checkbox input[type="checkbox"]:disabled + label,
.checkbox input[type="radio"]:disabled + label
opacity: 0.65;
.checkbox input[type="checkbox"]:disabled + label::before,
.checkbox input[type="radio"]:disabled + label::before
background-color: #eee;
cursor: not-allowed;
.checkbox.checkbox-circle label::before
border-radius: 50%;
.checkbox.checkbox-inline
margin-top: 0;
.checkbox-warning input[type="checkbox"]:checked + label::before,
.checkbox-warning input[type="radio"]:checked + label::before
background-color: #007bff;
border-color: #007bff;
.checkbox-warning input[type="checkbox"]:checked + label::after,
.checkbox-warning input[type="radio"]:checked + label::after
color: #fff;
.checkbox-warning input[type="checkbox"]:indeterminate + label::before,
.checkbox-warning input[type="radio"]:indeterminate + label::before
background-color: #007bff;
border-color: #007bff;
.checkbox-warning input[type="checkbox"]:indeterminate + label::after,
.checkbox-warning input[type="radio"]:indeterminate + label::after
background-color: #fff;
.checkbox input[type="checkbox"]:checked + label::after
font-family: "FontAwesome";
content: "\f00c";
input[type="checkbox"]:focus+label::before
animation: ripple 1s ease-out;
@keyframes ripple
0%
transform: scale(0, 0);
opacity: 1;
20%
transform: scale(25, 25);
opacity: 1;
100%
opacity: 0;
transform: scale(40, 40);
<div class="form-check form-check-inline checkbox checkbox-warning checkbox-inline pl-0 text-left">
<input class="form-check-input" type="checkbox" id="check1" name="enquiry" >
<label class="form-check-label label-font" for="inlineCheckbox1">Approved Leaves</label>
</div>
【问题讨论】:
此链接对您有帮助吗? javatpoint.com/oprweb/test.jsp?filename=CSScheckboxstyle3 感谢您的回复...我想在整个应用程序中应用涟漪效果,您能帮我看看我的代码中的错误在哪里吗?我想在样式表中添加代码只是,所以如果可能的话,请你更新我的代码..iam 试图保持像这样codepen.io/lehollandaisvolant/pen/GqmBGA 的涟漪效应,但我没有得到准确 【参考方案1】:我显示代码。我发现结构有些错误,请看下面的代码。
比较标签和输入的id
HTML 代码:
<div class="form-check form-check-inline checkbox checkbox-warning checkbox-inline pl-0 text-left">
<input class="form-check-input" type="checkbox" id="check1" name="enquiry" >
<label class="form-check-label label-font" for="check1">Approved Leaves</label>
</div>
CSS 代码:
.checkbox label::after
display: inline-block;
position: absolute;
width: 16px;
height: 16px;
left: 1px;
top: 4px;
font-weight: 100;
margin-left: -18px;
padding-left: 3px;
padding-top: 1px;
font-size: 11px;
color: #555;
input[type="checkbox"]:focus+label::after
animation: ripple 1s ease-out;
@keyframes ripple
0%
transform: scale(0, 0);
opacity: 0;
20%
transform: scale(0.5, 0.5);
opacity: 0.5;
100%
opacity: 1;
transform: scale(1, 1);
【讨论】:
codepen.io/lehollandaisvolant/pen/GqmBGA ,我想保持上面链接的涟漪效果..但我想我错过了一些地方,请帮助我以上是关于带有CSS的复选框波纹效果的主要内容,如果未能解决你的问题,请参考以下文章
在按钮标题上滑动文本,如带有 css 和 javascript 的选框(不是 jQuery)
如何制作一个检查按钮? (带有标签作为按钮的隐藏复选框:仅限 CSS)