티스토리 뷰
728x90
반응형
HTML
<div class="switcher">
<input type="checkbox" id="switcher-1" data-title1="on" data-title2="off" />
<label for="switcher-1"></label>
</div>
CSS
.switcher {position:relative;width:192px;height:42px;border-radius:25px;}
.switcher input {
-webkit-appearance: none;
appearance: none;
position: relative;
width: 192px;
height: 42px;
border-radius: 25px;
background-color: #0ab1a9;
border:1px solid #fff;
}
.switcher input:before,
.switcher input:after {
z-index: 2;
position: absolute;
top: 50%;
color: #fff;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
}
/*토글 좌측 텍스트*/
.switcher input:before {
content: attr(data-title1);
left: 30px;
color: #0ab1a9;
font-size: 16px;
-webkit-transition: color 0.5s, left 0.5s;
-moz-transition: color 0.5s, left 0.5s;
-ms-transition: color 0.5s, left 0.5s;
-o-transition: color 0.5s, left 0.5s;
transition: color 0.5s, left 0.5s;
}
/*토글 우측 텍스트*/
.switcher input:after {
content: attr(data-title2);
right: 30px;
color: #0ab1a9;
font-size: 16px;
-webkit-transition: color 0.5s, right 0.5s;
-moz-transition: color 0.5s, right 0.5s;
-ms-transition: color 0.5s, right 0.5s;
-o-transition: color 0.5s, right 0.5s;
transition: color 0.5s, right 0.5s;
}
/*토클 바 (head)*/
.switcher label {z-index:1;position:absolute;top:1px;bottom:1px;border-radius:25px;background-color: #fff;}
/*토글 좌측 텍스트 활성화시*/
.switcher input:checked:before {
color: #0ab1a9;
left:38px;
font-weight: 500;
-webkit-transition: color 0.5s 0.2s, left 0.5s 0.2s;
-moz-transition: color 0.5s 0.2s, left 0.5s 0.2s;
-ms-transition: color 0.5s 0.2s, left 0.5s 0.2s;
-o-transition: color 0.5s 0.2s, left 0.5s 0.2s;
transition: color 0.5s 0.2s, left 0.5s 0.2s;
}
/*토글 우측 텍스트 비활성화시*/
.switcher input:checked:after {color: #fff;}
/*토글바가 좌측으로 이동시*/
.switcher input:checked + label {
left: 0;
right: 82px;
-webkit-transition: left 0.5s, right 0.4s 0.2s;
-moz-transition: left 0.5s, right 0.4s 0.2s;
-ms-transition: left 0.5s, right 0.4s 0.2s;
-o-transition: left 0.5s, right 0.4s 0.2s;
transition: left 0.5s, right 0.4s 0.2s;
}
/*토글 좌측 텍스트 비활성화시*/
.switcher input:not(:checked):before {color: #fff;}
/*토글 우측 텍스트 활성화시*/
.switcher input:not(:checked):after {
color: #0ab1a9;
right:38px;
font-weight: 500;
-webkit-transition: color 0.5s 0.2s, right 0.5s 0.2s;
-moz-transition: color 0.5s 0.2s, right 0.5s 0.2s;
-ms-transition: color 0.5s 0.2s, right 0.5s 0.2s;
-o-transition: color 0.5s 0.2s, right 0.5s 0.2s;
transition: color 0.5s 0.2s, right 0.5s 0.2s;
}
/*토글바가 우측 이동시*/
.switcher input:not(:checked) + label {
left: 82px;
right: 0;
-webkit-transition: left 0.4s 0.2s, right 0.5s;
-moz-transition:left 0.4s 0.2s, right 0.5s;
-ms-transition:left 0.4s 0.2s, right 0.5s;
-o-transition:left 0.4s 0.2s, right 0.5s;
transition:left 0.4s 0.2s, right 0.5s;
}
728x90
반응형
'Programming language > HTML & CSS' 카테고리의 다른 글
뷰포트 정리 (0) | 2018.12.13 |
---|---|
하위 엘리먼트 존재 유무 체크 css (0) | 2018.11.23 |
tooltip( 말풍선 ) CSS (2) (0) | 2018.10.17 |
tooltip( 말풍선 ) CSS (1) (0) | 2018.07.12 |
FOUC 현상 (0) | 2017.09.15 |
댓글
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Angular
- svg 폰트
- Aptana
- react-router-dom
- git checkout -b
- 앵귤러
- CSS
- JsDoc
- svg모션
- Intrinsic
- 자바스크립트
- react
- React.StrictMode
- git
- Vue3
- svg icon font
- cordova
- anime.js
- 태그
- RefreshToken
- 리프래시토큰
- 반복문
- vue-router
- 아이콘 폰트 만들기
- icon font
- interceptors
- IntrinsicElements
- 내장요소
- 코도바
- for of 구문
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함