๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Lect & Tip/html, css, scss

~ + ์ธ์ ‘ ํ˜•์ œ ์„ ํƒ์ž๋ฅผ ์ด์šฉํ•œ No javascript ํ† ๊ธ€ ์ƒ์„ธ๊ฒ€์ƒ‰ ํ™”๋ฉด CSS๋งŒ์œผ๋กœ ํผ๋ธ”๋ฆฌ์‹ฑํ•˜๊ธฐ

by ๋‚ฏ์„ ๊ณต๊ฐ„2019 2019. 8. 16.

๋ชฉ์ฐจ

    ~ + ์ธ์ ‘ ํ˜•์ œ ์„ ํƒ์ž๋ฅผ ์ด์šฉํ•œ No javascript ํ† ๊ธ€ ์ƒ์„ธ๊ฒ€์ƒ‰ ํ™”๋ฉด CSS๋งŒ์œผ๋กœ ํผ๋ธ”๋ฆฌ์‹ฑํ•˜๊ธฐ

    ์ƒ์„ธ๊ฒ€์ƒ‰ ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ ์ƒ์„ธ ๊ฒ€์ƒ‰์šฉ ์˜ต์…˜๋“ค์ด ๋ณด์—ฌ์ง€๊ณ , ์ƒ์„ธ๋ฒ„ํŠผ์„ ๋‹ค์‹œ ํ•œ๋ฒˆ ๋ˆŒ๋Ÿฌ์„œ ํ† ๊ธ€ํ•˜๋ฉด ์ƒ์„ธ๊ฒ€์ƒ‰์ด ์‚ฌ๋ผ์ง€๋Š” ๊ฒƒ์„ ๊ตฌํ˜„ํ•˜๋ ค๋ฉด ๋ณดํ†ต์€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ์“ธ ์ˆ˜ ๋ฐ–์— ์—†๋‹ค.

    ํ•˜๋‹ค๋ชปํ•ด ๋ถ€ํŠธ์ŠคํŠธ๋žฉ์„ ์‚ฌ์šฉํ•œ๋‹ค๊ณ  ํ•˜๋”๋ผ๋„, ๊ฐ„๋‹จํ•œ ํ† ๊ธ€ ํ•จ์ˆ˜๋ฅผ ์ ์šฉํ•ด์•ผ๋งŒ ํ•œ๋‹ค.

    ํ•˜์ง€๋งŒ ์Šคํƒ€์ผ ์ฒดํฌ๋ฐ•์Šค๋ฅผ ์‘์šฉํ•˜๋ฉด, ์Šคํฌ๋ฆฝํŠธ์˜ ๋„์›€์—†์ด ์ƒ์„ธ ๊ฒ€์ƒ‰ ํ† ๊ธ€์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

    ์›๋ฆฌ๋Š” checkbox์˜ ์ธ์ ‘ ์—˜๋ ˆ๋จผํŠธ์— ์ƒ์„ธ๊ฒ€์ƒ‰ ์˜์—ญ์ด ๋†“์ด๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

    input[type="checkbox"]+ ์„ ํƒ์ž๋Š” ์ธ์ ‘ํ˜•์ œ ์„ ํƒ์ž๊ธฐ ๋•Œ๋ฌธ์—, label_text์— ์–‘๋ณดํ•˜๊ณ , 

    input[type="checkbox"]~ ํ˜•์ œ์„ ํƒ์ž๋ฅผ ์ด์šฉํ•ด์„œ

    .styledBtnToggle input[type="checkbox"]~.searchDetail {
        display: none;
    }
    
    .styledBtnToggle input[type="checkbox"]:checked~.searchDetail {
        display: flex;
        padding: 25px 20px;
    }

    ์ด์™€ ๊ฐ™์ด ์˜์—ญ์„ ์ˆจ๊ธฐ๊ณ  ๋‚˜ํƒ€๋‚ธ๋‹ค.

    display:flex๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒƒ์€ ํ•ด๋‹น ์˜์—ญ์˜ ์Šคํƒ€์ผ์„ ๋ฐ˜์‘ํ˜•์œผ๋กœ ํผ๋ธ”์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์‚ฌ์šฉํ–ˆ์„ ๋ฟ์ด๋‹ค. block์œผ๋กœ ์ฒ˜๋ฆฌํ•ด๋„ ๋ฌด๋ฐฉํ•˜๋‹ค.

    ๋ฐ๋ชจ ํ™”๋ฉด์€ http://bcode.shop/contents/contents/list.php ์—์„œ ํ™•์ธํ•˜๋ฉด ๋œ๋‹ค.

    ์ „์ฒด ์†Œ์Šค๋ฅผ ๊ณต๊ฐœํ•  ์ˆ˜๋Š” ์—†์ง€๋งŒ, ํ•ต์‹ฌ์ด ํฌํ•จ๋œ ์†Œ์Šค ์ผ๋ถ€๋ฅผ ๊ณต๊ฐœํ•ด ๋‘˜ํ…Œ๋‹ˆ, ์„ผ์Šค ์žˆ๊ฒŒ ๊ฐ–๋‹ค ์“ฐ์‹œ๊ธธ...

    HTML

                    <div class="listHeader">
                        <div class="contentsLock center-block container-fluid">
                            <nav>
                                <ul class="float-left dateFilter">
                                    <li><input class="btn btn-sm btn-default categoryBtn" type="button" value="๋งค์‰ฌ์—…">
                                    </li>
                                    <li><input class="btn btn-sm btn-default active categoryBtn" type="button" value="์˜ค๋ฆฌ์ง€๋„">
                                    </li>
                                    <li><input class="btn btn-sm btn-default categoryBtn" type="button" value="๋ฐฉ์†ก๋ถ„">
                                    </li>
                                    <li><input class="btn btn-sm btn-default categoryBtn" type="button" value="All">
                                    </li>
                                    <li><select class="form-control selectpicker noborder customCarets" style="width:120px;"
                                            name="ctrlSortValue">
                                            <option>๋“ฑ๋ก์ผ</option>
                                            <option>๋ฐฉ์†ก(๊ฒŒ์‹œ)์ผ</option>
                                        </select>
                                    </li>
                                    <li><input class="btn btn-sm btn-default timeBtn" type="button" value="์˜ค๋Š˜"></li>
                                    <li><input class="btn btn-sm btn-default timeBtn active" type="button" value="์ด๋ฒˆ์ฃผ"></li>
                                    <li><input class="btn btn-sm btn-default timeBtn" type="button" value="์ด๋ฒˆ๋‹ฌ"></li>
                                    <li><input class="btn btn-sm btn-default timeBtn" type="button" value="์˜ฌํ•ด"></li>
                                    <li class="datePicker2">
                                        <div class="form-group date">
                                            <div class="input-group date" id="datetimepicker1" data-target-input="nearest">
                                                <input type="text" class="form-control datetimepicker-input"
                                                    data-target="#datetimepicker1" data-toggle="datetimepicker"
                                                    name="ctrlDatePickerValue" />
                                                <div class="input-group-append" data-target="#datetimepicker1"
                                                    data-toggle="datetimepicker">
                                                    <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                                                </div>
                                            </div>
                                        </div>
                                        -
                                        <div class="form-group date">
                                            <div class="input-group date" id="datetimepicker2" data-target-input="nearest">
                                                <input type="text" class="form-control datetimepicker-input"
                                                    data-target="#datetimepicker2" data-toggle="datetimepicker"
                                                    name="ctrlDatePickerValue" />
                                                <div class="input-group-append" data-target="#datetimepicker2"
                                                    data-toggle="datetimepicker">
                                                    <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                </ul>
                                <ul class="float-right">
                                    <li class="float-right"><input type="text" class="form-control listSearch"
                                            name="listSearch" placeholder="Search"></li>
                                    <li><input type="button" class="btnReload" value="์ดˆ๊ธฐํ™”" id="onRefresh"></li>
                                    <li><input type="button" value="๊ฒ€์ƒ‰" class="btn btn-primary btn-listSearch"
                                            id="onSearch">
                                    </li>
                                    <li class="ml10 btnSpacer">
                                        <!-- ์ƒ์„ธ๋ฒ„ํŠผ ์œ„์น˜ -->
                                    </li>
                                </ul>
                            </nav>
                            <label class="styledBtnToggle">
                                <input type="checkbox" name="styledBtnToggle"> <span class="label-text"></span>
                                <!--Search Detail Area -->
                                <div class="searchDetail contentsLock center-block container-fluid">
                                    <div class="searchDetailLeft">
                                        <div class="titleForm"><label for="keywordChn">์ฑ„๋„</label></div>
                                        <div class="keyForm">
                                            <select class="form-control selectpicker noborder" data-live-search="true"
                                                title="์ฑ„๋„๋ช…" name="ctrlSortValue">
                                                <option>TvN</option>
                                                <option>xTVN</option>
                                                <option>Olive</option>
                                                <option>oTvn</option>
                                                <option>JTBC</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="searchDetailRight">
                                        <div class="titleForm"><label for="keywordChn">ํ”„๋กœ๊ทธ๋žจ</label></div>
                                        <div class="keyForm">
                                            <select class="form-control selectpicker noborder" data-live-search="true"
                                                title="ํ”„๋กœ๊ทธ๋žจ๋ช…" name="ctrlSortValue">
                                                <option>๋ชจํ…” ๋ธ๋ฃจ๋‚˜</option>
                                                <option>์•…๋งˆ๊ฐ€ ๋„ˆ์˜ ์ด๋ฆ„๋”ฐ์œ„๋ฅผ...</option>
                                                <option>600์ผ ์ƒ์กด์ž</option>
                                                <option>์• ํ”Œ ์™“์ฒ˜</option>
                                                <option>์•„์Šค๋‚  ์—ฐ์†Œ๊ธฐ</option>
                                                <option>์ˆ˜๋ฏธ๋„ค๋ฐค์ฐฌ</option>
                                                <option>์ˆ˜์š”ํญ์‹ํšŒ</option>
                                                <option>๋จน๊ณ ์ฃฝ์€๋…€์„๋“ค</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="searchDetailLeft">
                                        <div class="titleForm">
                                            <select class="form-control selectpicker noborder" title="์ถœ์—ฐ"
                                                name="ctrlSortValue">
                                                <option>์ถœ์—ฐ</option>
                                                <option>์Šคํƒญ</option>
                                            </select></div>
                                        <div class="keyForm">
                                            <select class="form-control selectpicker noborder" data-live-search="true"
                                                title="์ถœ์—ฐ์ž๋ช…, ๋ฐฐ์—ญ๋ช…, ๋ณธ๋ช…" name="ctrlSortValue">
                                                <option>์ด์ง€์€</option>
                                                <option>์•„์ด์œ </option>
                                                <option>์•„์ด์šฐ</option>
                                                <option>์•„์• ์œ </option>
                                                <option>์•„์•„์œ </option>
                                                <option>์•„์–ด์œ </option>
                                                <option>์–ด์ด์œ </option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="searchDetailRight flexColumn">
                                        <div class="flexColumnItem">
                                            <div class="titleForm">Publish ์ด๋ ฅ
                                            </div>
                                            <div class="keyForm">
                                                <label class="styledRadio">
                                                    <input type="radio" name="radio1" id="radio1" checked> <span
                                                        class="label-text">All</span>
                                                </label>
                                                <label class="styledRadio">
                                                    <input type="radio" name="radio1"> <span class="label-text">์žˆ์Œ</span>
                                                </label>
                                                <label class="styledRadio">
                                                    <input type="radio" name="radio1"> <span class="label-text">์—†์Œ</span>
                                                </label>
                                            </div>
                                        </div>
                                        <div class="flexColumnItem">
                                            <div class="titleForm">Live ์ด๋ ฅ</div>
                                            <div class="keyForm">
                                                <label class="styledRadio">
                                                    <input type="radio" name="radio2" id="radio1" checked> <span
                                                        class="label-text">All</span>
                                                </label>
                                                <label class="styledRadio">
                                                    <input type="radio" name="radio2"> <span class="label-text">์žˆ์Œ</span>
                                                </label>
                                                <label class="styledRadio">
                                                    <input type="radio" name="radio2"> <span class="label-text">์—†์Œ</span>
                                                </label></div>
                                            <div class="titleForm">AI ๊ฒฐ๊ณผ ์ •๋ณด</div>
                                            <div class="keyForm">
                                                <label class="styledRadio">
                                                    <input type="radio" name="radio3" id="radio1" checked> <span
                                                        class="label-text">All</span>
                                                </label>
                                                <label class="styledRadio">
                                                    <input type="radio" name="radio3"> <span class="label-text">์žˆ์Œ</span>
                                                </label>
                                                <label class="styledRadio">
                                                    <input type="radio" name="radio3"> <span class="label-text">์—†์Œ</span>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- Search Detail Area -->
                            </label>
                        </div>
                    </div>

    CSS

    /*styledBtnToggle +detailSearch No script Toggle*/
    .btnSpacer {
        width: 70px;
    }
    
    label.styledBtnToggle {
        margin-bottom: 0;
    }
    
    .styledBtnToggle input[type="checkbox"]~.searchDetail {
        display: none;
    }
    
    .styledBtnToggle input[type="checkbox"]:checked~.searchDetail {
        display: flex;
        padding: 25px 20px;
    }
    
    .styledBtnToggle input[type="checkbox"]+.label-text {
        position: absolute;
        top: 20px;
        right: 20px;
    }
    
    .styledBtnToggle input[type="checkbox"] {
        position: absolute;
        top: 0;
        right: 0;
        margin: 0
    }
    
    .styledBtnToggle input[type="checkbox"]+.label-text:before {
        content: "์ƒ์„ธ";
        height: 30px;
        line-height: 30px;
        text-align: center;
        border-radius: 4px;
        width: 70px;
        background: #fff;
        color: #4d79f6;
        border: 1px solid #4d79f6;
        display: inline-block;
        margin-left: -3px;
        vertical-align: baseline;
    }
    
    .styledBtnToggle input[type="checkbox"]:checked+.label-text:before {
        content: "์ƒ์„ธ";
        color: #fff;
        background: #4d79f6;
        animation: effect 250ms ease-in;
    }
    

    noscript

    ๋ฐ˜์‘ํ˜•

    ๋Œ“๊ธ€