更改Select2的默认字体 [英] Change default font of Select2

查看:431
本文介绍了更改Select2的默认字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Select2插件将搜索功能添加到我的下拉菜单中.但是,我希望将这些下拉菜单的字体样式设置为与其他字段相同的字体:font-family: Arial, Helvetica, sans-serif;

I am using the Select2 plugin to add the search feature to my dropdowns. However, I want the font style of these drop downs to be set to the same font as my other fields: font-family: Arial, Helvetica, sans-serif;

我的选择" HTML:

My 'Select' HTML:

<label>Department</label>
<select class='js-example-basic-single' name="department" id="department" required>
  <option value="Dep 1">Dep 1 </option>
  <option value="Dep 2">Dep 2 </option> etc.....
</select>

我的JavaScript:

My JavaScript:

$(document).ready(function() {
  $(".js-example-basic-single").select2({
    placeholder: "Please Select an option",
    allowClear: true
  });
});

我确定对此有一个简单的答案,但似乎找不到答案.

I'm sure there is an easy answer to this, but couldn't seem to find one.

推荐答案

select2js Select HTML标记的不同部分提供不同的类和id 选择器/em>.

要具体更改Select OPTION font-size (选择OPTION font-size ),我们可以使用以下类选择器来更改符合我们要求的acc.

For specific changing the Select OPTION font-size, we can use the following class selector to change the same acc to our requirement.

.select2-results__options{
        font-size:14px !important;
 }

这篇关于更改Select2的默认字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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