Bulma CSS与Select2 jQuery插件 [英] Bulma css with select2 jquery plugin

查看:74
本文介绍了Bulma CSS与Select2 jQuery插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 select2 插件.io/documentation/elements/form/"rel =" noreferrer>布尔玛 css框架,但在前端看起来有些混乱.我使用引导程序尝试了此操作,是的,因为select2具有引导程序兼容性,所以没有问题.

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 bootstrap compatibility.

HTML:

<div class="field">
  <label class="label">Role</label>
     <p class="control">
         <span class="select is-fullwidth">
            <select2 v-model="form.role"
                    placeholder="Select Role"
                    name="role"
                    :value="form.role"
                    :multiple="false"
             >
                <option></option>
                 <option v-for="role in roles" :value="role.id">{{ role.display_name }}</option>
         </select2>

     </span>
   </p>
</div>

推荐答案

我成功了,也许我的例子可以为您提供帮助.

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

查看

<div class="field">
    <label class="label">Hair</label>
    <div class="control">
        <select2 class="is-medium" v-model="post.custom_data.hair" :options="{}">
            @foreach (config('post.cat.hair') as $id => $value)
                <option value="{{ $id }}">{{ __($value) }}</option>
            @endforeach
        </select2>
    </div>
</div>

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;
                }
            }
        }
    }
}

结果

希望它能帮助^^

这篇关于Bulma CSS与Select2 jQuery插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆