- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想设计一个拨动开关,如下图所示:
我开发了一个拨动开关。下面给出了 html 和 css 代码的详细信息。我想知道如何用铃铛图标替换圆圈。
/* ============================================================
RESET
============================================================ */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
background: transparent;
border: 0;
margin: 0;
padding: 0;
vertical-align: baseline;
}
body {
line-height: 1;
}
h1, h2, h3, h4, h5, h6 {
clear: both;
font-weight: normal;
}
ol, ul {
list-style: none;
}
blockquote {
quotes: none;
}
blockquote:before, blockquote:after {
content: '';
content: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
a img {
border: none;
}
/* ============================================================
GLOBALS
============================================================ */
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
background-color: #dc8c96;
color: #505050;
font-family: "Ubuntu", sans-serif;
font-weight: 300;
font-size: 16px;
line-height: 1.8;
}
/* Headings */
h1, h2, h3, h4, h5, h6 {
line-height: 1;
font-weight: 400;
font-family: "Roboto Slab", serif;
}
a {
text-decoration: none;
color: #dc8c96;
}
a:hover {
color: #ca5160;
}
/* clear floated divs */
.clearfix:after {
content: "";
display: table;
clear: both;
}
/* ============================================================
TEMPLATE
============================================================ */
#wrapper {
width: 100%;
margin: 0 auto;
}
#main {
background-color: #fff;
padding: 30px 0;
}
.container {
width: 100%;
max-width: 1000px;
margin: 0 auto;
padding: 0 30px;
}
/* ============================================================
INFO BAR
============================================================ */
.info-bar {
background-color: #ca5160;
text-align: center;
}
.info-bar a.icon {
margin: 0 5px;
padding: 10px 0;
color: #fff;
font-size: 20px;
position: relative;
}
.info-bar a.icon[data-title]:hover:after {
position: absolute;
top: 100%;
left: 0;
z-index: 20px;
content: attr(data-title);
padding: 5px 10px;
background-color: #ca5160;
font-family: "Ubuntu", sans-serif;
color: #fff;
font-size: 12px;
white-space: nowrap;
}
/* ============================================================
HEADER
============================================================ */
header .branding {
padding: 30px 0;
background-color: #dc8c96;
}
header .branding .container {
padding: 0 30px 0 90px;
}
header .social {
float: left;
width: 100%;
height: 60px;
text-align: right;
line-height: 60px;
}
header .social a {
display: inline-block;
text-indent: -9999px;
font-size: 0;
margin: 15px 0;
width: 30px;
height: 30px;
background-size: 30px 30px;
margin-left: 5px;
background-image: url("../img/core/social-light.png");
background-image: url("../img/core/social-light.svg"), none;
background-size: 180px 30px;
}
header .social a.fb {
background-position: 0 0;
}
header .social a.twitter {
background-position: -30px 0;
}
header .social a.googleplus {
background-position: -60px 0;
}
header .social a.rss {
background-position: -90px 0;
}
header .social a.email {
background-position: -120px 0;
}
header .social a.search {
background-position: -150px 0;
}
header .social a:hover {
opacity: 0.4;
}
header .logo {
float: left;
width: 60px;
height: 60px;
margin-left: -60px;
}
header .site-title {
background-color: #ca5160;
padding: 10px 30px;
text-align: center;
}
header .site-title h1 {
margin: 0;
padding: 0;
color: #fff;
font-size: 12px;
}
/* ============================================================
FOOTER
============================================================ */
footer {
padding: 30px 0;
}
footer .container {
padding: 0 30px;
}
footer aside {
width: 33.3333%;
float: left;
}
footer aside.logo {
text-align: right;
}
footer ul {
list-style-type: none;
margin: 0;
padding: 0;
}
footer ul a {
color: #fff;
}
footer ul a:hover {
color: #f4dadd;
}
footer .copyright {
margin-top: 30px;
text-align: center;
}
footer .copyright span {
color: #fff;
}
footer .copyright a {
color: #f4dadd;
}
/* ============================================================
FUSION ADS
============================================================ */
#fusionads {
position: fixed;
top: 10px;
right: 10px;
z-index: 20;
padding: 20px;
background: rgba(255, 255, 255, 0.95);
font-size: 12px;
line-height: 1.2;
-webkit-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.1);
-moz-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.1);
box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.1);
}
#fusionads .fusion-wrap {
display: block;
margin: 0 auto 10px auto;
width: 130px;
}
#fusionads a.fusion-text {
display: block;
color: #646464;
}
#fusionads a.fusion-img {
display: block;
margin-bottom: 10px;
width: 130px;
height: 100px;
background-color: #fff;
}
#fusionads a.fusion-img img {
display: block;
margin: 0 0 10px 0;
}
#fusionads a.fusion-poweredby {
color: #ff3c50;
}
#close-fusionad {
position: fixed;
top: 10px;
right: 10px;
z-index: 30;
width: 20px;
height: 20px;
background-color: #505050;
text-align: center;
line-height: 20px;
color: #fff;
font-size: 12px;
font-weight: 700;
}
/* ============================================================
MEDIA QUERIES
============================================================ */
@media all and (max-width: 960px) {
/* footer */
footer aside {
width: 100%;
float: none;
margin-bottom: 15px;
}
footer aside:last-child {
margin-bottom: 0;
}
footer aside.logo {
text-align: center;
}
footer ul {
text-align: center;
}
footer ul li {
display: inline-block;
}
footer ul li:after {
content: "\2022";
}
footer ul li:last-child:after {
content: none;
}
footer ul li a {
margin: 0 10px;
}
}
@media all and (max-width: 400px) {
header .branding {
padding: 15px 0;
}
header .branding .container {
padding: 0 30px;
}
header .social {
float: none;
width: 100%;
text-align: center;
line-height: 30px;
height: 30px;
}
header .social a {
margin: 0 5px;
}
header .logo {
float: none;
margin: 0 auto;
margin-bottom: 15px;
}
}
/* ============================================================
COMMON
============================================================ */
#wrapper {
min-width: 600px;
}
.settings {
display: table;
width: 100%;
}
.settings .row {
display: table-row;
}
.settings .question,
.settings .switch {
display: table-cell;
vertical-align: middle;
padding: 10px;
}
.settings .question {
width: 600px;
font-family: "Roboto Slab", serif;
font-size: 20px;
}
/* ============================================================
COMMON
============================================================ */
.cmn-toggle {
position: absolute;
margin-left: -9999px;
visibility: hidden;
}
.cmn-toggle + label {
display: block;
position: relative;
cursor: pointer;
outline: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* ============================================================
SWITCH 1 - ROUND
============================================================ */
input.cmn-toggle-round + label {
padding: 2px;
width: 112px;
height: 50px;
background-color: #dddddd;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
-ms-border-radius: 60px;
-o-border-radius: 60px;
border-radius: 60px;
}
input.cmn-toggle-round + label:before, input.cmn-toggle-round + label:after {
display: block;
position: absolute;
top: 1px;
left: 1px;
bottom: 1px;
content: "";
}
input.cmn-toggle-round + label:before {
right: 1px;
background-color: #f1f1f1;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
-ms-border-radius: 60px;
-o-border-radius: 60px;
border-radius: 60px;
-webkit-transition: background 0.4s;
-moz-transition: background 0.4s;
-o-transition: background 0.4s;
transition: background 0.4s;
}
input.cmn-toggle-round + label:before {
background-color: red;
/* background-image: url("../img/notOff.png");
background-repeat: no-repeat;*/
}
input.cmn-toggle-round + label:after {
width: 50px;
background-color: #fff;
/*background-image: url("../img/notOn.png");
background-repeat: no-repeat;*/
-webkit-border-radius: 100%;
-moz-border-radius: 100%;
-ms-border-radius: 100%;
-o-border-radius: 100%;
border-radius: 100%;
-webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
-webkit-transition: margin 0.4s;
-moz-transition: margin 0.4s;
-o-transition: margin 0.4s;
transition: margin 0.4s;
}
input.cmn-toggle-round + label:after {
background-image: url("../img/notOff.png");
background-repeat: no-repeat;
}
input.cmn-toggle-round + label:before {
background-image: url("../img/notOn.png");
background-repeat: no-repeat;
}
input.cmn-toggle-round:checked + label:before {
background-color: #8ce196;
}
input.cmn-toggle-round:checked + label:after {
margin-left: 60px;
}
/* ============================================================
SWITCH 2 - ROUND FLAT
============================================================ */
input.cmn-toggle-round-flat + label {
padding: 2px;
width: 120px;
height: 60px;
background-color: #dddddd;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
-ms-border-radius: 60px;
-o-border-radius: 60px;
border-radius: 60px;
-webkit-transition: background 0.4s;
-moz-transition: background 0.4s;
-o-transition: background 0.4s;
transition: background 0.4s;
}
input.cmn-toggle-round-flat + label:before, input.cmn-toggle-round-flat + label:after {
display: block;
position: absolute;
content: "";
}
input.cmn-toggle-round-flat + label:before {
top: 2px;
left: 2px;
bottom: 2px;
right: 2px;
background-color: #fff;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
-ms-border-radius: 60px;
-o-border-radius: 60px;
border-radius: 60px;
-webkit-transition: background 0.4s;
-moz-transition: background 0.4s;
-o-transition: background 0.4s;
transition: background 0.4s;
}
input.cmn-toggle-round-flat + label:after {
top: 4px;
left: 4px;
bottom: 4px;
width: 52px;
background-color: #dddddd;
-webkit-border-radius: 52px;
-moz-border-radius: 52px;
-ms-border-radius: 52px;
-o-border-radius: 52px;
border-radius: 52px;
-webkit-transition: margin 0.4s, background 0.4s;
-moz-transition: margin 0.4s, background 0.4s;
-o-transition: margin 0.4s, background 0.4s;
transition: margin 0.4s, background 0.4s;
}
input.cmn-toggle-round-flat:checked + label {
background-color: #8ce196;
}
input.cmn-toggle-round-flat:checked + label:after {
margin-left: 60px;
background-color: #8ce196;
}
/* ============================================================
SWITCH 3 - YES NO
============================================================ */
input.cmn-toggle-yes-no + label {
padding: 2px;
width: 120px;
height: 60px;
}
input.cmn-toggle-yes-no + label:before, input.cmn-toggle-yes-no + label:after {
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
color: #fff;
font-family: "Roboto Slab", serif;
font-size: 20px;
text-align: center;
line-height: 60px;
}
input.cmn-toggle-yes-no + label:before {
background-color: #dddddd;
content: attr(data-off);
-webkit-transition: -webkit-transform 0.5s;
-moz-transition: -moz-transform 0.5s;
-o-transition: -o-transform 0.5s;
transition: transform 0.5s;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
input.cmn-toggle-yes-no + label:after {
background-color: #8ce196;
content: attr(data-on);
-webkit-transition: -webkit-transform 0.5s;
-moz-transition: -moz-transform 0.5s;
-o-transition: -o-transform 0.5s;
transition: transform 0.5s;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
input.cmn-toggle-yes-no:checked + label:before {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
input.cmn-toggle-yes-no:checked + label:after {
-webkit-transform: rotateY(0);
-moz-transform: rotateY(0);
-ms-transform: rotateY(0);
-o-transform: rotateY(0);
transform: rotateY(0);
}
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<!-- title and meta -->
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0" name="viewport">
<title>CSS Toggle Switch</title>
<!-- css -->
<link href="css/base.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="js/toggle.js"></script>
<!-- js -->
<!--[if lt IE 9]><script src="js/html5shiv.min.js"></script><![endif]-->
</head>
<body>
<div id="wrapper">
<div id="main">
<div class="container">
<div class="settings">
<div class="row">
<div class="question">
Do you like bananas?
</div>
<div class="switch">
<input id="cmn-toggle-1" class="cmn-toggle cmn-toggle-round" type="checkbox">
<label for="cmn-toggle-1"></label>
</div>
</div><!-- /row -->
</div>
</div>
</div><!-- #main -->
</div><!-- /#wrapper -->
</body>
</html>
我想用下面给出的示例钟形图像替换圆圈:
不知道该怎么做。请帮忙。
最佳答案
我们来了!!你只需要将你的图像作为背景。
input.cmn-toggle-round:checked + label:after {
margin-left: 60px;
background-image: url("http://i.stack.imgur.com/hlAG5.png"); // your image
}
/* ============================================================
RESET
============================================================ */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
background: transparent;
border: 0;
margin: 0;
padding: 0;
vertical-align: baseline;
}
body {
line-height: 1;
}
h1, h2, h3, h4, h5, h6 {
clear: both;
font-weight: normal;
}
ol, ul {
list-style: none;
}
blockquote {
quotes: none;
}
blockquote:before, blockquote:after {
content: '';
content: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
a img {
border: none;
}
/* ============================================================
GLOBALS
============================================================ */
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
background-color: #dc8c96;
color: #505050;
font-family: "Ubuntu", sans-serif;
font-weight: 300;
font-size: 16px;
line-height: 1.8;
}
/* Headings */
h1, h2, h3, h4, h5, h6 {
line-height: 1;
font-weight: 400;
font-family: "Roboto Slab", serif;
}
a {
text-decoration: none;
color: #dc8c96;
}
a:hover {
color: #ca5160;
}
/* clear floated divs */
.clearfix:after {
content: "";
display: table;
clear: both;
}
/* ============================================================
TEMPLATE
============================================================ */
#wrapper {
width: 100%;
margin: 0 auto;
}
#main {
background-color: #fff;
padding: 30px 0;
}
.container {
width: 100%;
max-width: 1000px;
margin: 0 auto;
padding: 0 30px;
}
/* ============================================================
INFO BAR
============================================================ */
.info-bar {
background-color: #ca5160;
text-align: center;
}
.info-bar a.icon {
margin: 0 5px;
padding: 10px 0;
color: #fff;
font-size: 20px;
position: relative;
}
.info-bar a.icon[data-title]:hover:after {
position: absolute;
top: 100%;
left: 0;
z-index: 20px;
content: attr(data-title);
padding: 5px 10px;
background-color: #ca5160;
font-family: "Ubuntu", sans-serif;
color: #fff;
font-size: 12px;
white-space: nowrap;
}
/* ============================================================
HEADER
============================================================ */
header .branding {
padding: 30px 0;
background-color: #dc8c96;
}
header .branding .container {
padding: 0 30px 0 90px;
}
header .social {
float: left;
width: 100%;
height: 60px;
text-align: right;
line-height: 60px;
}
header .social a {
display: inline-block;
text-indent: -9999px;
font-size: 0;
margin: 15px 0;
width: 30px;
height: 30px;
background-size: 30px 30px;
margin-left: 5px;
background-image: url("../img/core/social-light.png");
background-image: url("../img/core/social-light.svg"), none;
background-size: 180px 30px;
}
header .social a.fb {
background-position: 0 0;
}
header .social a.twitter {
background-position: -30px 0;
}
header .social a.googleplus {
background-position: -60px 0;
}
header .social a.rss {
background-position: -90px 0;
}
header .social a.email {
background-position: -120px 0;
}
header .social a.search {
background-position: -150px 0;
}
header .social a:hover {
opacity: 0.4;
}
header .logo {
float: left;
width: 60px;
height: 60px;
margin-left: -60px;
}
header .site-title {
background-color: #ca5160;
padding: 10px 30px;
text-align: center;
}
header .site-title h1 {
margin: 0;
padding: 0;
color: #fff;
font-size: 12px;
}
/* ============================================================
FOOTER
============================================================ */
footer {
padding: 30px 0;
}
footer .container {
padding: 0 30px;
}
footer aside {
width: 33.3333%;
float: left;
}
footer aside.logo {
text-align: right;
}
footer ul {
list-style-type: none;
margin: 0;
padding: 0;
}
footer ul a {
color: #fff;
}
footer ul a:hover {
color: #f4dadd;
}
footer .copyright {
margin-top: 30px;
text-align: center;
}
footer .copyright span {
color: #fff;
}
footer .copyright a {
color: #f4dadd;
}
/* ============================================================
FUSION ADS
============================================================ */
#fusionads {
position: fixed;
top: 10px;
right: 10px;
z-index: 20;
padding: 20px;
background: rgba(255, 255, 255, 0.95);
font-size: 12px;
line-height: 1.2;
-webkit-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.1);
-moz-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.1);
box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.1);
}
#fusionads .fusion-wrap {
display: block;
margin: 0 auto 10px auto;
width: 130px;
}
#fusionads a.fusion-text {
display: block;
color: #646464;
}
#fusionads a.fusion-img {
display: block;
margin-bottom: 10px;
width: 130px;
height: 100px;
background-color: #fff;
}
#fusionads a.fusion-img img {
display: block;
margin: 0 0 10px 0;
}
#fusionads a.fusion-poweredby {
color: #ff3c50;
}
#close-fusionad {
position: fixed;
top: 10px;
right: 10px;
z-index: 30;
width: 20px;
height: 20px;
background-color: #505050;
text-align: center;
line-height: 20px;
color: #fff;
font-size: 12px;
font-weight: 700;
}
/* ============================================================
MEDIA QUERIES
============================================================ */
@media all and (max-width: 960px) {
/* footer */
footer aside {
width: 100%;
float: none;
margin-bottom: 15px;
}
footer aside:last-child {
margin-bottom: 0;
}
footer aside.logo {
text-align: center;
}
footer ul {
text-align: center;
}
footer ul li {
display: inline-block;
}
footer ul li:after {
content: "\2022";
}
footer ul li:last-child:after {
content: none;
}
footer ul li a {
margin: 0 10px;
}
}
@media all and (max-width: 400px) {
header .branding {
padding: 15px 0;
}
header .branding .container {
padding: 0 30px;
}
header .social {
float: none;
width: 100%;
text-align: center;
line-height: 30px;
height: 30px;
}
header .social a {
margin: 0 5px;
}
header .logo {
float: none;
margin: 0 auto;
margin-bottom: 15px;
}
}
/* ============================================================
COMMON
============================================================ */
#wrapper {
min-width: 600px;
}
.settings {
display: table;
width: 100%;
}
.settings .row {
display: table-row;
}
.settings .question,
.settings .switch {
display: table-cell;
vertical-align: middle;
padding: 10px;
}
.settings .question {
width: 600px;
font-family: "Roboto Slab", serif;
font-size: 20px;
}
/* ============================================================
COMMON
============================================================ */
.cmn-toggle {
position: absolute;
margin-left: -9999px;
visibility: hidden;
}
.cmn-toggle + label {
display: block;
position: relative;
cursor: pointer;
outline: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* ============================================================
SWITCH 1 - ROUND
============================================================ */
input.cmn-toggle-round + label {
padding: 2px;
width: 112px;
height: 50px;
background-color: #dddddd;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
-ms-border-radius: 60px;
-o-border-radius: 60px;
border-radius: 60px;
}
input.cmn-toggle-round + label:before, input.cmn-toggle-round + label:after {
display: block;
position: absolute;
top: 1px;
left: 1px;
bottom: 1px;
content: "";
}
input.cmn-toggle-round + label:before {
right: 1px;
background-color: #f1f1f1;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
-ms-border-radius: 60px;
-o-border-radius: 60px;
border-radius: 60px;
-webkit-transition: background 0.4s;
-moz-transition: background 0.4s;
-o-transition: background 0.4s;
transition: background 0.4s;
}
input.cmn-toggle-round + label:before {
background-color: red;
/* background-image: url("../img/notOff.png");
background-repeat: no-repeat;*/
}
input.cmn-toggle-round + label:after {
width: 50px;
background-color: #fff;
background-image: url("http://i.stack.imgur.com/hlAG5.png");
background-repeat: no-repeat;*/
-webkit-border-radius: 100%;
-moz-border-radius: 100%;
-ms-border-radius: 100%;
-o-border-radius: 100%;
border-radius: 100%;
-webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
-webkit-transition: margin 0.4s;
-moz-transition: margin 0.4s;
-o-transition: margin 0.4s;
transition: margin 0.4s;
}
input.cmn-toggle-round + label:after {
background-image: url("http://i.stack.imgur.com/MF9Yy.png");
background-repeat: no-repeat;
}
input.cmn-toggle-round + label:before {
background-image: url("../img/notOn.png");
background-repeat: no-repeat;
}
input.cmn-toggle-round:checked + label:before {
background-color: #8ce196;
}
input.cmn-toggle-round:checked + label:after {
margin-left: 60px;
background-image: url("http://i.stack.imgur.com/hlAG5.png");
}
/* ============================================================
SWITCH 2 - ROUND FLAT
============================================================ */
input.cmn-toggle-round-flat + label {
padding: 2px;
width: 120px;
height: 60px;
background-color: #dddddd;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
-ms-border-radius: 60px;
-o-border-radius: 60px;
border-radius: 60px;
-webkit-transition: background 0.4s;
-moz-transition: background 0.4s;
-o-transition: background 0.4s;
transition: background 0.4s;
}
input.cmn-toggle-round-flat + label:before, input.cmn-toggle-round-flat + label:after {
display: block;
position: absolute;
content: "";
}
input.cmn-toggle-round-flat + label:before {
top: 2px;
left: 2px;
bottom: 2px;
right: 2px;
background-color: #fff;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
-ms-border-radius: 60px;
-o-border-radius: 60px;
border-radius: 60px;
-webkit-transition: background 0.4s;
-moz-transition: background 0.4s;
-o-transition: background 0.4s;
transition: background 0.4s;
}
input.cmn-toggle-round-flat + label:after {
top: 4px;
left: 4px;
bottom: 4px;
width: 52px;
background-color: #dddddd;
-webkit-border-radius: 52px;
-moz-border-radius: 52px;
-ms-border-radius: 52px;
-o-border-radius: 52px;
border-radius: 52px;
-webkit-transition: margin 0.4s, background 0.4s;
-moz-transition: margin 0.4s, background 0.4s;
-o-transition: margin 0.4s, background 0.4s;
transition: margin 0.4s, background 0.4s;
}
input.cmn-toggle-round-flat:checked + label {
background-color: #8ce196;
}
input.cmn-toggle-round-flat:checked + label:after {
margin-left: 60px;
background-color: #8ce196;
}
/* ============================================================
SWITCH 3 - YES NO
============================================================ */
input.cmn-toggle-yes-no + label {
padding: 2px;
width: 120px;
height: 60px;
}
input.cmn-toggle-yes-no + label:before, input.cmn-toggle-yes-no + label:after {
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
color: #fff;
font-family: "Roboto Slab", serif;
font-size: 20px;
text-align: center;
line-height: 60px;
}
input.cmn-toggle-yes-no + label:before {
background-color: #dddddd;
content: attr(data-off);
-webkit-transition: -webkit-transform 0.5s;
-moz-transition: -moz-transform 0.5s;
-o-transition: -o-transform 0.5s;
transition: transform 0.5s;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
input.cmn-toggle-yes-no + label:after {
background-color: #8ce196;
content: attr(data-on);
-webkit-transition: -webkit-transform 0.5s;
-moz-transition: -moz-transform 0.5s;
-o-transition: -o-transform 0.5s;
transition: transform 0.5s;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
input.cmn-toggle-yes-no:checked + label:before {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
input.cmn-toggle-yes-no:checked + label:after {
-webkit-transform: rotateY(0);
-moz-transform: rotateY(0);
-ms-transform: rotateY(0);
-o-transform: rotateY(0);
transform: rotateY(0);
}
<div id="wrapper">
<div id="main">
<div class="container">
<div class="settings">
<div class="row">
<div class="question">
Do you like bananas?
</div>
<div class="switch">
<input id="cmn-toggle-1" class="cmn-toggle cmn-toggle-round" type="checkbox">
<label for="cmn-toggle-1"></label>
</div>
</div><!-- /row -->
</div>
</div>
</div><!-- #main -->
</div><!-- /#wrapper -->
关于html - 在 ionic 中设计定制的拨动开关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34460940/
我想在聚焦时使用 ion-input 更改 ion-item 内的 ion-label 颜色。 我可以使用 --highlight-color-focused: yellow; 更改 ion-item
我想用 ionic 3 ion-list (或任何在 Ionic 3 中有效的东西)来显示水平列表而不是典型的垂直列表。 寻找解决方案 没有大量的 css 或难以维护的代码。
我目前使用 ionic 和我的 cordova 插件同时开发一个应用程序。我想知道如何使用文件 plugins/fetch.json 从本地文件系统更新我的插件。有什么想法吗? 最佳答案 使用 ion
当我在 ionic 项目文件夹中运行 ionic link 命令时,我收到以下错误消息 “除非您在 Ionic 项目文件夹中,否则您无法运行此命令” 我的系统信息。 Cordova CLI:6.3.1
如何注释 ion-row这样它就可以填满剩余的空间? 对于以下示例,黄色行“内容”应展开,直到占用所有剩余(绿色)空间。 Example text
我正在尝试构建一个 ionic 应用程序,但是当我运行 npm run ionic:build -–prod 时,出现以下错误: npm run ionic:build -–prod npm ERR!
我想在 ion-footer-bar 中添加两个按钮,如图片,但我的代码无法正常工作。 Button 333333333 Button
请有人澄清一下我什么时候会使用 ion-nav-view反对 ion-view ?我正在学习 AngularJS/Ionic(我对 AngularJS 有基本的了解;并且想使用 Ionic 来增强它)
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 1年前关闭。 Improve t
item-avatar 在我的项目中不起作用,它根本不显示 item-avatar 元素。 Recent Conversations
我正在使用带有属性interface="popover"的ion-select。弹出窗口在 select 下方打开,这使得弹出窗口非常小。 我发现,如果 ion-select 中有 10 个或更多项目
我创建了一个带有电容器的新项目 ionic。我使用 ionic 选择,但我有一个新的 ionic 选择选项,带有大文本,而不是在输入中分布。 Plaga/Enfermedad Al
如何像 ionic 中的许多应用程序一样滑动切换段?我在 ionic 官方文档中找不到任何 api。我只能找到this有用的线程。 但它似乎并不完美。有更好的解决办法吗? ionic 信息: Cord
我正在开发一个登录表单,所以在我的 中我有一个 (用作登录表单的容器)我想垂直居中。我用 css flexbox 和其他 css 技巧尝试了不同的方法,但对我没有任何作用!该卡片保留在页面顶部。你
我想在 ionic 选择(组合框)更改时隐藏和显示文本框 例如我有: ionic 选择中的 1 和 2如果我选择 1 文本框将隐藏,如果我选择 2 文本框将出现 这是我当前的代码: .ts onCha
我尝试在 ionic 4 中使用 ion-button 实现一个按钮,但没有样式输出,问题出在哪里,求助。 最佳答案 请使用以下代码 这里是 ionic v4 按钮的文档。 https://beta
我有一个在 ionic serve 中运行良好的应用程序。我现在正在尝试创建一个构建——这通常有效,但今天我遇到了问题。 ionic package build ios --profile devel
我正在使用 Ionic 2,在我的应用程序中我正在创建一个表单,如果出现验证错误,信息图标将出现在相关输入字段的右侧。 HTML如下,
我正在与一个远程团队一起开发 Ionic 1 应用程序,最近我们的版本彼此不喜欢。我想知道我是否也一直在从事 Ionic 2 项目,无论出于何种原因,我的 CLI “认为”这些应用程序也是 Ionic
我需要禁用默认 ion-ripple-effect在“ ionic 按钮”中。 我无法禁用 pointer-events因为我需要它。 PS:我引用了以下帖子,但找不到适合 Ionic 4
我是一名优秀的程序员,十分优秀!