开发者

Asp.Net Elements Doesn't Get Style Properties From Css File

开发者 https://www.devze.com 2023-03-21 05:59 出处:网络
I don\'t know if there\'s a different Css usage in Asp.net but I just can\'t make it work. I target my .css file with

I don't know if there's a different Css usage in Asp.net but I just can't make it work.

I target my .css file with

<link href="Style/Style.css" type="text/css" rel="Stylesheet" />

code.

And there are <div> and <table> elements.

The开发者_运维技巧 table has an id and its properties in the css file are working normal. But I can't say the same thing about <div> and <a> tags.

Let's take this example:

<div align="center" id="bla">

And I use id in css file in different ways. I first used #bla { } or div#bla or div #bla { }, then I used .bla { } or div.bla { } or div .bla { } with making class="bla" instead of id="bla" in Aspx page, they all did not work.

But when I moved the code from css file to Aspx file between <style type="text/css"><style/> tags, it worked normal.

The same behaviour happens in <a> too. But it does not in <table>.

Is there a different usage? What do I miss?

More info at http://jsfiddle.net/npTc6/


It could be a pathing issue to your CSS file. If you have multiple CSS files, it could also be the order of your CSS files. You should verify that you have the correct path to your CSS file and that you have the correct file name referenced in your code. Often, the most simple mistakes are the most frustrating.

UPDATE: Your CSS has a space between the "a" anchor and the class name, and I believe you need a leading slash on your image references (if not there already).

Example:

a .Russia
{
    display: block;
    background-image: url("/Images/Default/Russia.png");
    width: 173px;
    height: 173px;
}

try...

a.Russia
{
    display: block;
    background-image: url("/Images/Default/Russia.png");
    width: 173px;
    height: 173px;
}


It was a problem common in Asp.Net. Just about background properties. Standart CSS background-image code had some issues so there are variations. I tried many, then fixed it by using this one:
background: url(/Images/Default/Turkiye.png);

0

精彩评论

暂无评论...
验证码 换一张
取 消