Reputation: 141
I have a problem with applying css on textboxes in asp.net!!
Here is my textbox:
<asp:TextBox ID="TextBox1" CssClass="textbox" runat="server" Height="22px" Width="128px"
BackColor="#CCCCCC"></asp:TextBox>
As u see I added CssClass to the textbox. Here is the css i am using
.textbox
{
background-color: Red;
font-weight: bold;
}
What is the problem? I googled, but can't find the answer!!
Upvotes: 1
Views: 9619
Reputation: 457
try to add important
input[type=”text”]
{
background-color: Red!important;
font-weight: bold;
}
Upvotes: -1
Reputation: 8265
It's a css style rule precedence problem. BackColor property that you have specified translates to style="background-color:#cccccc"
. so this color is applied instead of red (css class). and also DonNetNuke css rules may override your rules.
So, use more specific rules (like the one @Gayatri mentioned in his answer). Use browsers 'Inspect element' future to determine witch style is overriding others.
Upvotes: 0
Reputation: 17724
Remove your BackColor="#CCCCCC"
attribute.
Asp.net renders this as in inline css style on the element.
Inline styles have more precedence in CSS over css classes.
<asp:TextBox ID="TextBox1" CssClass="textbox" runat="server"
Height="22px" Width="128px"></asp:TextBox>
.textbox
{
background-color: Red;
font-weight: bold;
}
Upvotes: 6
Reputation: 554
input.textbox
{
background-color: Red;
font-weight: bold;
}
Please use input.textbox instead pf only .textbox.
Upvotes: 1