简体   繁体   中英

Why css is not getting applied to my web page?

I have an asp.net form in which I am trying to apply some font settings to a textbox through css.This is what I have in my CSS:

body 
{

}

@font-face {
    font-family: 'Lohit Devanagari',serif;  
    src: url('http://fonts.googleapis.com/earlyaccess/lohitdevanagari.css');
    font-weight: normal;
    font-style: normal;
}

.txtQues
{
    font-family: 'Lohit Devanagari',serif;   
    font-size:14px;
    background-color:Yellow;
}

Below is a part of my page source where I have added the css to the page:

<head>
 <title>Question Master</title>
 <link href="../FontSettings.css" rel="stylesheet" type="text/css" />
 <meta name="google-translate-customization" 
 content="3280487709591956-   dc3fc45d489f056a-g5378ebab0cbcd0a4-12"/>   
</head>

The TextBox:

<asp:TextBox ID="txtQuestion" runat="server" Height="101px" TextMode="MultiLine" Width="627px" meta:resourcekey="txtQuestionResource1"  EnableTheming="True" 
ontextchanged="txtQuestion_TextChanged" CssClass="txtQues"></asp:TextBox>

As soon as I apply the css to the form, I see a change in the color of the text box in the design window, which tells me that css is being applied,but when I run the code on the browser I find that neither the text box color changes nor the font.Kindly help me and let me know where am I going wrong.

Remove the @font-face and import the file. The css allready uses font-face. Try:

@import url("http://fonts.googleapis.com/earlyaccess/lohitdevanagari.css");
body 
{

}
.txtQues
{
    font-family: 'Lohit Devanagari',serif;   
    font-size:14px;
    background-color:Yellow;
}

In the below code remove "EnableTheming" or make it false.

<asp:TextBox ID="txtQuestion" runat="server" Height="101px" TextMode="MultiLine" Width="627px" meta:resourcekey="txtQuestionResource1"  EnableTheming="True" ontextchanged="txtQuestion_TextChanged" CssClass="txtQues"></asp:TextBox>

Also try to keep important for your styles in CSS like below.

.txtQues
{
font-family: 'Lohit Devanagari',serif !important;   
font-size:14px !important;
background-color:Yellow !important;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM