Yii2:如何更改选择二小部件的FONT-FAMILY

问题描述 投票:0回答:2

我有一个select2小部件,我需要改变它的字体家庭。

<?= $form->field($model, 'my_number')
    ->widget(Select2::classname(), [
        'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'],
        'class' => 'form-control',
]) ?>

引导没有一个类来改变它,所以我想我需要改变它的风格。

css yii2 jquery-select2-4 font-family
2个回答
0
投票

您可以添加的样式,类似如下:

<?= $form->field($model, 'my_number')
->widget(Select2::classname(), [
    'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'],
    'class' => 'form-control',
    'options' => ['style' => 'font:yourfontfamilly'],
]) ?>

0
投票

当您使用Kartik Select2,如果你想改变Font-family定制你需要更新都在select2-krajee.css file.They添加分为2组以下类的选择2的font-family

Changing Font Family

For the Placeholder and selected Option

.select2-container--krajee .select2-selection{
   font-family:Roboto, sans-serif !important;
}

For the Drop-down Options

.select2-container--krajee .select2-results__option{
   font-family:Roboto, sans-serif !important;
}

Changing Font color/size

For the Selected option

.select2-container--krajee .select2-selection--single .select2-selection__rendered{
    color:red !important;
}

For the Default Placeholder

.select2-container--krajee .select2-selection--single .select2-selection__placeholder{
    color:red !important;
}

为了改变颜色的下拉选项用于同一个类被列出的选项font-family在第一部分之上,即.select2-container--krajee .select2-results__option

希望能帮助到你

© www.soinside.com 2019 - 2024. All rights reserved.