간단한 체크 박스 스위치를 만들었습니다. 여기 JSFiddle : http://jsfiddle.net/aseVX입니다. 작은 원형 점프를 클릭하면 왼쪽에서 오른쪽으로 부드럽게 이동하려고합니다. 그리고 오른쪽에서 왼쪽으로. CSS 전환 추가를 시도했는데 제대로 작동하지 않았습니다. 내가 뭘 잘못하고 있는지 생각해? 표류이 코멘트에 말했듯이 당신은 폭이 설정되는 것을 특징으로하기 때문에CSS 전환이 적용되지 않습니다.
/*Checkbox Switch*/
.switch p, .switch label {
display: inline;
}
.switch label {
margin-left: 10px;
}
.switch label > span {
background-color: rgba(0, 0, 0, 0.1);
border: 1px solid #A6A6A6;
width: 50px;
height: 30px;
position: relative;
display: inline-block;
vertical-align: middle;
cursor: pointer;
border-radius: 50px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
-webkit-transition: all .15s linear;
-moz-transition: all .15s linear;
-ms-transition: all .15s linear;
-o-transition: all .15s linear;
transition: all .15s linear;
}
.switch input[type="checkbox"]:checked + span {
background-color: #316C94;
border: 1px solid rgba(0, 0, 0, 0.4);
}
.switch span span {
background-color: #fff;
border: 1px solid #A6A6A6;
width: 24px;
height: 24px;
position: absolute;
top: 2px;
left: 2px;
cursor: pointer;
border-radius: 50px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
-webkit-transition: all .15s ease;
-moz-transition: all .15s ease;
-ms-transition: all .15s ease;
-o-transition: all .15s ease;
transition: all .15s ease;
}
.switch label > span:hover span {
width: 30px;
}
.switch input[type="checkbox"]:checked + span span {
right: 2px;
left: auto;
border: none;
}
/*Checkbox Switch > Disabled*/
.switch input[type="checkbox"]:disabled + span {
background-color: rgba(0, 0, 0, 0.1) !important;
border: 1px solid #A6A6A6 !important;
}
.switch input[type="checkbox"]:disabled + span span, .switch input[type="checkbox"]:disabled + span span:hover {
background-color: #fff !important;
border: 1px solid #A6A6A6 !important;
width: 24px !important;
}
'left : auto;'와 같이 숫자 값에서 키워드로 전환 할 수 없습니다. – Adrift
무엇을 하시겠습니까? – Leo
그럴 것입니다. 'span' 너비는 정적입니까? – Adrift