Bulma css with select2 jquery plugin

后端 未结 2 1274
灰色年华
灰色年华 2021-02-06 11:13

I tried to implement select2 plugin using the Bulma css framework but it seems messy in frontend. I tried this using bootstrap and yes there\'s no problem since select2 has a bo

2条回答
  •  遇见更好的自我
    2021-02-06 11:31

    I made it work, maybe my example can help you.

    View

    @foreach (config('post.cat.hair') as $id => $value) @endforeach

    SASS

    .select2-wrapper {
        .select2-container {
            .select2-selection {
                transition: border-color $speed;
                font-family: $family-sans-serif;
                height: 2.285em;
                line-height: 1.5;
                font-size: 1rem;
                outline: none !important;
                display: inline-flex;
                align-items: center;
                width: 100%;
                border-color: $border;
                border-radius: $radius;
                &:hover {
                    border-color: $border-hover;
                }
                .select2-selection__rendered {
                    padding-left: 0.75em;
                    padding-right: 0.75em;
                }
                .select2-selection__arrow {
                    display: none;
                }
            }
    
            &.select2-container--open {
                .select2-selection {
                    border-color: $primary;
                    &:hover {
                        border-color: $primary;
                    }
                }
            }
        }
    
        &.is-medium {
            .select2-container {
                .select2-selection {
                    font-size: $size-5;
                }
            }
        }
        &.is-large {
            .select2-container {
                .select2-selection {
                    font-size: $size-4;
                }
            }
        }
    }
    
    .select2-container {
        .select2-dropdown {
            border-color: $primary;
    
            .select2-search {
                margin: 10px;
                .select2-search__field {
                    @extend .input;
                    border-radius: $radius !important;
                }
            }
    
            .select2-results__options {
                max-height: 210px;
                .select2-results__option {
                    padding: 0.75em;
                    font-family: $family-sans-serif;
                    font-size: 1rem;
    
                    &.select2-results__option--highlighted {
                        background: $primary;
                    }
                }
            }
        }
    }
    

    Result

    Hope it helps ^^

提交回复
热议问题