checkbox switch ios

2017. 10. 24. 18:48·DEV/CSS

1. http://callmenick.com/post/css-toggle-switch-examples 에 들어간다.


2. Get source 버튼을 눌러 다운을 받아준다.


3. 받은 파일 압축을 풀어준다.


4. css폴더안에 style.css 를 프로젝트 안에 넣어준다.


5. <head></head> 사이에 css를 지정해준다.

<link href="경로/css/switch.css?ver=1" rel="stylesheet" />

이름을 바꿔 사용해도 무방하다.


6. 기본형은 아래와 같고 응용해서 사용하면 된다.

<input id="cmn-toggle-1" class="cmn-toggle cmn-toggle-round" type="checkbox">
<label for="cmn-toggle-1"></label>


7. 자바스크립트 Checkbox Checked 여부확인은 아래와 같이 하면된다.

<input id="cmn-toggle-1" class="cmn-toggle cmn-toggle-round" type="checkbox" onclick="test(this);">
<label for="cmn-toggle-1"></label>

function test(obj){

var cb_id = document.getElementById(obj.getAttribute('id'));

      if(cb_id.checked){

          console.log("true");       // 클릭

      }else{

   console.log("false");        // 클릭 X

}

}

function test(obj){

var cb_id = $(obj).attr('id');

      if($("#"+cb_id).prop("checked")){

          console.log("true");       // 클릭

      }else{

   console.log("false");        // 클릭 X

}

}

8.  스위치의 크기 색깔등을 바꾸고 싶을때는 css 파일을 열어 필요한 부분만 수정해주면 된다.

/*그냥 보일때*/

input.cmn-toggle-round + label { width:50px; height:25px;}

input.cmn-toggle-round + label:after {width:25px;}

/*클릭 후 원 위치*/

input.cmn-toggle-round:checked + label:after { margin-left:23px;}

/*클릭 시 색깔*/

input.cmn-toggle-round:checked + label:before { background-color : #68a4c4}

등등 입맛에 맞게 사용하면 된다.

저작자표시 비영리 변경금지 (새창열림)

'DEV > CSS' 카테고리의 다른 글

선택 동작 없애기  (0) 2017.11.22
HTML 색상표  (0) 2017.10.27
부트스트랩 테이블 정렬  (0) 2017.08.30
input, textarea, button 파란색 테두리 제거 및 색상 바꾸기  (0) 2017.08.29
비율 유지 이미지 object-fit  (0) 2017.08.16
'DEV/CSS' 카테고리의 다른 글
  • 선택 동작 없애기
  • HTML 색상표
  • 부트스트랩 테이블 정렬
  • input, textarea, button 파란색 테두리 제거 및 색상 바꾸기
modric
modric
  • modric
    dev log
    modric
  • 전체
    오늘
    어제
    • 분류 전체보기 (70)
      • DEV (58)
        • Linux (12)
        • JavaScript (5)
        • PHP (4)
        • MySql (4)
        • HTML (7)
        • CSS (9)
        • Spring (13)
        • flutter (1)
        • 오류 (2)
        • devOps (1)
      • 기타 (5)
      • 트렌드 (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 미디어로그
    • 위치로그
    • 방명록
    • HTML
    • CSS
    • PHP
    • JavaScript
    • Spring
    • Linux
  • 링크

    • 공부하는 소담아빠
    • 타올이
  • 공지사항

  • 인기 글

  • 태그

    js
    MYSQL
    팩토리얼
    linux
    Android
    iframe
    mariadb10
    centos 7
    컴파일
    update
    100!
    제거
    mariadb 10
    터치
    클릭
    메타버스
    Safari
    php
    lastinsertid
    ios
    build
    exist
    테두리
    Destination
    centos7
    파란색
    height
    크롬
    factorial
    넘침
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.5
modric
checkbox switch ios
상단으로

티스토리툴바