Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在@Html.DropDownList Jquery UI对话中选择2 apply(应用于小宽度)?_Jquery_Css_Asp.net Mvc_Jquery Select2_Jquery Ui Dialog - Fatal编程技术网

在@Html.DropDownList Jquery UI对话中选择2 apply(应用于小宽度)?

在@Html.DropDownList Jquery UI对话中选择2 apply(应用于小宽度)?,jquery,css,asp.net-mvc,jquery-select2,jquery-ui-dialog,Jquery,Css,Asp.net Mvc,Jquery Select2,Jquery Ui Dialog,我在MVC中工作,我有一个div,我使用jQuery将其作为对话框打开,如下所示: <div id="dialog"> <form action="" method="post" dir="ltr"> <div> @Html.DropDownList("LKP_Managers", null, " &qu

我在MVC中工作,我有一个
div
,我使用jQuery将其作为对话框打开,如下所示:

<div id="dialog">
    <form action="" method="post" dir="ltr">
        <div>
            @Html.DropDownList("LKP_Managers", null, " ", htmlAttributes: new { @class = "form-control " })
        </div>
    </form>
</div>
单击后,它将变为可见:

<input type="button" id="model.NationalID" class="btn btn-info"  onclick="javascript:OnEdit(id);" />

是否可以修改上述CSS,使其仅在“我的对话框”下拉列表中实现?

您可以在下拉列表中添加自定义类,然后修改CSS以仅在该类上操作。这将向您的
元素添加一个名为
lkp managers
的类:

@Html.DropDownList(
  "LKP_Managers",
  null,
  " ",
  htmlAttributes: new { @class = "form-control lkp-managers" }
)
然后,您可以将CSS应用于该类:

.select2-container.lkp-managers {
    width: 100% !important;
}
然后,您的select2定义需要将设置为
解析
,以便根据
元素的
样式
属性确定宽度:

$('.your-select2-definition').select2({
  /* ... */
  width: 'resolve', 
})
另一个选项是只需在select2实例本身上设置主题,然后就可以修改搜索字段宽度和容器:

$('.your-select2-definition').select2({
  /* ... */
  theme: 'lkp-managers', 
})
以你的风格为准

.select2-container--lkp-managers {
    width: 100% !important;
}

.lkp-managers .select2-search--dropdown .select2-search__field {
    width: 98% !important;
}

您可以将自定义类添加到下拉列表中,然后修改CSS以仅对该类进行操作。这将向您的
元素添加一个名为
lkp managers
的类:

@Html.DropDownList(
  "LKP_Managers",
  null,
  " ",
  htmlAttributes: new { @class = "form-control lkp-managers" }
)
然后,您可以将CSS应用于该类:

.select2-container.lkp-managers {
    width: 100% !important;
}
然后,您的select2定义需要将设置为
解析
,以便根据
元素的
样式
属性确定宽度:

$('.your-select2-definition').select2({
  /* ... */
  width: 'resolve', 
})
另一个选项是只需在select2实例本身上设置主题,然后就可以修改搜索字段宽度和容器:

$('.your-select2-definition').select2({
  /* ... */
  theme: 'lkp-managers', 
})
以你的风格为准

.select2-container--lkp-managers {
    width: 100% !important;
}

.lkp-managers .select2-search--dropdown .select2-search__field {
    width: 98% !important;
}

你好@user802782,我的答案最终对你有用吗?你好@user802782,我的答案最终对你有用吗?