gpt4 book ai didi

c# - 更改 DropDownListFor 样式

转载 作者:行者123 更新时间:2023-11-28 10:56:58 27 4
gpt4 key购买 nike

一直在尝试多种方法来更改 DropDownListFor 元素的样式。要么我做错了什么,要么有什么东西压倒了它。我已经尝试在 View 元素和 CSS 中更改它。但没有成功。

查看:

<div style="width: 100%; ">
<div style="float: left;"> @Html.DropDownListFor(model => model.FranPID, new SelectList(Model.FranchiseList, "FranchiseID", "FranBusinessName", new { @class = "selectStyle" }))</div>
</div>

CSS:

.selectStyle {
border: 1px solid #93A9C8;
padding: 2px;
font-size: 1em;
color: #444;
width: 200px;
border-radius: 3px 3px 3px 3px;
-webkit-border-radius: 3px 3px 3px 3px;
-moz-border-radius: 3px 3px 3px 3px;
-o-border-radius: 3px 3px 3px 3px;
}

编辑已解决:

正确调用:

<div style="width: 100%; ">
<div style="float: left;"> @Html.DropDownListFor(model => model.FranPID, new SelectList(Model.FranchiseList, "FranchiseID", "FranBusinessName"), new { @class = "selectStyle" })</div>
</div>

糟糕的是我在 SelectList 调用中有新的.. 将它移出(更改 parans)并且一切正常

最佳答案

好吧,这是一种方式...如果有更好的方式,我希望其他人能告诉我,因为我需要学习更多!

在 View 中:

    <div id="products" class="container" >
<div class="row">
<div class="col-lg-10 col-md-5 col-sm-4 dropdownlist">
@Html.LabelFor(m => m.SelectedCategoryId)
@Html.DropDownList("id", Model.CategoryItems, new { @id = "ddlCategories", onchange = "this.form.submit();" })
</div>
</div>
</div>

在CSS中:

/* the width of the entire in div of id=product */
#products {
width: 100%;
}
/* any item in the div of id=product with its class having dropdownlist */
#products .dropdownlist{
font-size: 18px;
}
/* any dropdown in product id div */
#products select{
color: blue;
}
/* specifically, any item with id of ddlCategories in the div of id=product */
#products #ddlCategories
{
color: red;
}

希望这对您有所帮助。

关于c# - 更改 DropDownListFor 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22580556/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com