2012-11-02 20 views
1

我有這樣的HTML是由MVC3剃刀引擎產生的:我寫我的自動填充功能MVC3的site.css重寫我的自定義樣式

<div class="editor-field"> 
    <div id="autoComplete"> 
     @Html.EditorFor(model => Model.group_name, new { ID = "group_name" }) 
     @Html.ValidationMessageFor(model => Model.group_name) 
    </div> 
</div> 

我的自定義CSS:

#group_name input[type='text'], input[type='password'] 
{ 
    padding: 0px; 
    border: 1px solid black; 
    background-color: white; 
    overflow: hidden; 
    z-index: 99999; 
} 
#group_name input[type='text'], input[type='password'] ul 
{ 
    width: 100%; 
    list-style-position: outside; 
    list-style: none; 
    padding: 0; 
    margin: 0; 
} 
#group_name input[type='text'], input[type='password'] li 
{ 
    margin: 0px; 
    padding: 2px 5px; 
    cursor: default; 
    display: block; /* if width will be 100% horizontal scrollbar will apear  when scroll mode will be used */ /*width: 100%;*/ 
    font: menu; 
    font-size: 12px; /*  it is very important, if line-height not setted or setted in relative units scroll will be broken in firefox */ 
    line-height: 16px; 
    overflow: hidden; 
} 

但它被默認使用MVC 3解決方案的site.css覆蓋,它是這樣的:

input[type="text"], input[type="password"] 
{ 
    border: 1px solid #ccc; 
    padding: 2px; 
    font-size: 1.2em; 
    color: #444; 
    width: 200px; 
} 

有誰知道我必須寫什麼CSS來定位我的div和輸入html?謝謝。

+0

您的CSS是在網站CSS之後還是之前調用的?如果是之後會更好。你也應該更清楚地指定你的css,例如「div.mydividorclass輸入」 –

回答

0

我最終使用firebug來查看HTML的變化。 IE有它自己的javascript調試選項,但能夠實時看到li渲染並查看它的標籤幫助我編寫了我的css。

3

這是因爲CSS Specificity

您需要制定更具體的規則來覆蓋site.css樣式。

或者,只需覆蓋文件本身的site.css樣式即可。 Site.css不像一個不應該被覆蓋的樣式庫。這只是一個可以編輯/刪除的開始模板。