본문 바로가기
javaScript/jQuery

jQuery nice-select 다운 및 select 꾸미기

by mooyou 2024. 1. 10.
728x90
300x250

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Layer Popup with Nice-Select</title>
    <!-- jQuery 및 nice-select의 CDN을 이용한 스타일 및 스크립트 연결 -->
    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-nice-select/1.1.0/css/nice-select.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-nice-select/1.1.0/js/jquery.nice-select.min.js"></script>
    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
        }

        .mask {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5); /* 반투명한 검은색 배경 */
            display: none;
        }

        .popup {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
            display: none;
        }

        .close {
            position: absolute;
            top: 10px;
            right: 10px;
            font-size: 20px;
            cursor: pointer;
        }

        /* nice-select 스타일을 위한 추가 스타일 */
        .nice-select {
            width: 300px;
        }
        .nice-select .list {
            width: 100%;
        }
    </style>
</head>
<body>

<div class="wrap">
    <!-- nice-select 적용된 셀렉트 박스 -->
    <select id="selectBox" class="nice-select">
        <option value="option1">옵션 1</option>
        <option value="option2">옵션 2</option>
        <option value="option3">옵션 3</option>
    </select>
</div>


<script>
    // nice-select 초기화
    $(document).ready(function() {
        $('#selectBox').niceSelect();
    });
</script>

</body>
</html>

 

 

jQuery nice-select 다운로드 주소

https://jqueryniceselect.hernansartorio.com/

 

jQuery Nice Select

Usage 1. Include jQuery and the plugin. 2. Include the plugin styles, either the compiled CSS... ...or, ideally, import the SASS source (if you use SASS) in your main stylesheet for easier customization. @import 'nice-select'; // Or 'nice-select-prefixed'.

jqueryniceselect.hernansartorio.com

 

728x90
반응형

댓글