视图未拾取MVC .NET CSS [英] MVC .NET CSS not picked up by the View

查看:92
本文介绍了视图未拾取MVC .NET CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在MVC2网站上工作,但是在将我的对象放在视图上以继承css类时遇到了问题.

I am working on a MVC2 site and am having issues getting my objects on my views to inherit the css classes.

这是我的帮助对象和CSS,它们保存在母版页中链接的Site.css中.

Here is my helper object and CSS that is saved in the Site.css which is linked in the master page.

如果我将CSS放在主页上的标记中,这也可以正常工作.

This also works fine if I put the CSS in a tag on the masterpage.

<%= Html.ListBox("ExpenseItems", (System.Web.Mvc.SelectList)ViewData["ExpenseDefinitions"], new { @class = "optionlist" })%>

.optionlist
{
    width:100px;
    height:100px;
}

Browser HTML:
..
<link href="../Content/Site.css" rel="stylesheet" type="text/css" />
..
<select class="optionlist" id="ExpenseItems" multiple="multiple" name="ExpenseItems">
<option value="1">Test</option>
</select>

推荐答案

弄清楚了...无法将样式应用于列表.

Figured it out... Can't apply the style to the list.

出于某些原因,您需要将其应用于div,然后应用于CSS中的控件.

Some reason, you need to apply it to a div then apply to the control in CSS.

示例:

CSS:
.optionlist select
{
     width:100px;
     height:100px;
}

<div class="optionlist">
... Lisbox
</div>

这篇关于视图未拾取MVC .NET CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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