我有一个简单的Materialize开关元素,我想在里面添加一些文字。
MaterialiseCSS示例切换:
这是代码:
swaplast :: [a] -> [a]
所需的开关:
https://codepen.io/chiandet/pen/raNKbE
只需在开关内部取一些文字并使其成为正方形就足够了;有可能吗?
非常感谢!
答案 0 :(得分:2)
https://jsfiddle.net/55L52yww/190/
HTML
<div class="switch">
<label>
<input type="checkbox" class="upsellActiveToggle" checked="checked"><span class="lever">
<span class="off">Off</span>
<span class="on">On</span>
</span>
</label>
</div>
CSS:
.switch label input[type=checkbox]:checked+.lever {
background-color: #c3ccd9;
padding: 3px 0 0 10px;
}
.switch label .lever {
content: "";
display: inline-block;
position: relative;
width: 60px;
height: 21px;
background-color: rgba(0,0,0,0.38);
border-radius: 0;
margin-right: 10px;
transition: background 0.3s ease;
vertical-align: middle;
margin: 0 16px;
}
.switch label .lever:before, .switch label .lever:after {
content: "";
position: absolute;
display: inline-block;
width: 22px;
height: 22px;
border-radius: 0;
left: 0;
top: -1px;
transition: left 0.3s ease, background .3s ease, box-shadow 0.1s ease, transform .1s ease;
}
.switch label input[type=checkbox]:checked+.lever:before, .switch label input[type=checkbox]:checked+.lever:after {
left: 37px;
}
.switch label input[type=checkbox]+.lever span.off, .switch label input[type=checkbox]+.lever span.off {
display: none;
}
.switch label input[type=checkbox]+.lever span.on, .switch label input[type=checkbox]+.lever span.on {
display: inline-block;
padding: 3px 0 0 15px;
}
.switch label input[type=checkbox]:checked+.lever span.on, .switch label input[type=checkbox]:checked+.lever span.on {
display: none;
}
.switch label input[type=checkbox]:checked+.lever span.off, .switch label input[type=checkbox]:checked+.lever span.off {
display: inline-block;
}
.switch label input[type=checkbox]+.lever {
background-color: #111;
padding: 3px 0 0 15px;
}
你可能需要做一些更多样式来获得你真正需要的东西