我有一個ASP文本框控件。當用戶專注於文本框時,我想將文本框的背景顏色從灰色更改爲白色。asp文本框控件的CSS
這裏是css文件,但其重點放在文本框後沒有改變顏色。
<script language="javascript" type="text-javascript">
function DoFocus(txt)
{
txt.className = 'focus';
}
</script>
文本框
<asp:TextBox ID="txtFirstName" runat="server"
CssClass="textbox" MaxLength="50" Width="188px" onfocus="DoFocus(this)">
CSS
input.textbox, select, textarea
{
font-family : verdana, arial, snas-serif;
font-size : 11px;
color : #000000;
padding : 3px;
background : #f0f0f0;
border-left : solid 1px #c1c1c1;
border-top : solid 1px #cfcfcf;
border-right : solid 1px #cfcfcf;
border-bottom : solid 1px #6f6f6f;
}
input.textbox:focus, input.input_text_focus
{
border-color:#646464;
background-color:#ffcf03;
}
只是有一件事我要問,爲什麼強調工作時,我手動添加樣式到aspx頁面,而不是樣式表? – user478636 2011-04-10 08:39:35
這可能是其他樣式來自其他樣式表...嘗試使用'background-color:#ffffc0!important;'... – 2011-04-10 08:49:14
以及我剛剛在我的頁面中引用了1個樣式表。我只在我的項目中使用了1 – user478636 2011-04-10 09:12:31