채택완료

비밀글 체크박스를 토글 버튼으로 바꾸고싶어요..

2021-02-21 (일) 23:30:43 2,007

나리야 사용중인데요...

글쓰기에서 비밀글 체크박스를 토글버튼 (o   ) on  //  (  o) off  요런거

https://proto.io/freebies/onoff/

ios13 스타일로 적용하고 싶은데

어떻게 적용해야 할까요 ㅠㅠ?

그리고 온/오프 시 비밀번호 작성 칸을 보이고 안보이게 같이 연동하고싶은데..;; 가능할까요?

답변 2개

채택된 답변
+20 포인트
Copy
<style>

 

.onoffswitch {

    position: relative; width: 66px;

    -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;

}

.onoffswitch-checkbox {

    position: absolute;

    opacity: 0;

    pointer-events: none;

}

.onoffswitch-label {

    display: block; overflow: hidden; cursor: pointer;

    border: 2px solid #999999; border-radius: 20px;

}

.onoffswitch-inner {

    display: block; width: 200%; margin-left: -100%;

    transition: margin 0.3s ease-in 0s;

}

.onoffswitch-inner:before, .onoffswitch-inner:after {

    display: block; float: left; width: 50%; height: 20px; padding: 0; line-height: 20px;

    font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;

    box-sizing: border-box;

}

.onoffswitch-inner:before {

    content: "ON";

    padding-left: 10px;

    background-color: #34A7C1; color: #FFFFFF;

}

.onoffswitch-inner:after {

    content: "OFF";

    padding-right: 10px;

    background-color: #EEEEEE; color: #999999;

    text-align: right;

}

.onoffswitch-switch {

    display: block; width: 18px; margin: 1px;

    background: #FFFFFF;

    position: absolute; top: 0; bottom: 0;

    right: 42px;

    border: 2px solid #999999; border-radius: 20px;

    transition: all 0.3s ease-in 0s; 

}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {

    margin-left: 0;

}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {

    right: 0px; 

}

</style>

<script>

<div class="onoffswitch">

    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" tabindex="0" checked>

    <label class="onoffswitch-label" for="myonoffswitch">

        <span class="onoffswitch-inner"></span>

        <span class="onoffswitch-switch"></span>

    </label>

</div>

</script>

위에 적어주신 사이트에 소스가 있네요  이대로 원하시는 부분에 붙혀넣으면 원하시는효과 나오실거에요 .

name="onoffswitch"  <- 이부분만 기존 값으로 바꿔서 테스트 해보셔요.

2021-02-24 (수) 10:26:32

이렇게 하는방법이 있네요 감사합니다

답변을 작성하려면 로그인이 필요합니다.