最近在做使用.net開發小型網站的時候,發現放入.net程式碼之後頁面特定區域定義好的CSS樣式莫名其妙的沒了,找了很多方法,結果發現居然是CSS裡的註解惹的禍。
原CSS程式碼如下view plaincopy to clipboardprint?
/*右側區域*/
.RightPart{width:230px;margin-top:10px;}
.RightPart{text-align:left;}
.RightPart .Title{background:url(../images/RightPartTitle.gif) no-repeat left top;padding-left:32px;height:47px;}
.RightPart .TitleR{background:url(../images/RightPartTitleRed.gif) no-repeat left top;padding-left:32px;height:47px;}
.RightPart .TitleG{background:url(../images/RightPartTitleG.gif) no-repeat left top;padding-left:32px;height:47px;}
.RightPart h3{font-size:14px;color:#FFF;}
.RightPart .LeftBorder{width:8px;background:url(../images/make_default_2_1.jpg) repeat-y left top;}
.RightPart .RightBorder{width:9px;background:url(../images/make_default_2_2.jpg) repeat-y right top;}
.RightPart .Content{width:205px;padding:0 5px;}
.RightPart ul{list-style:none;}
.RightPart li{display:block;background:url(../images/page_story_icon_ball.jpg) no-repeat left 3px;padding:3px 0 3px 15px;}
/*地圖分類*/
.RightPart .Category li{font-size:16px;font-weight:bold;background:url(../images/page_story_icon_ball.jpg) no-repeat left 5px;margin:4px 0 4px 10px;
.RightPart .Category .Line{background:left top;padding:0;margin:0 0 0 3px !Important;margin:-13px 0 0 3px;width:auto;height:4px;}
/**右側
.RightPart{width:230px;margin-top:10px;}
.RightPart{text-align:left;}
.RightPart .Title{background:url(../images/RightPartTitle.gif) no-repeat left top;padding-left:32px;height:47px;}
.RightPart .TitleR{background:url(../images/RightPartTitleRed.gif) no-repeat left top;padding-left:32px;height:47px;}
.RightPart .TitleG{background:url(../images/RightPartTitleG.gif) no-repeat left top;padding-left:32px;height:47px;}
.RightPart h3{font-size:14px;color:#FFF;}
.RightPart .LeftBorder{width:8px;background:url(../images/make_default_2_1.jpg) repeat-y left top;}
.RightPart .RightBorder{width:9px;background:url(../images/make_default_2_2.jpg) repeat-y right top;}
.RightPart .Content{width:205px;padding:0 5px;}
.RightPart ul{list-style:none;}
.RightPart li{display:block;background:url(../images/page_story_icon_ball.jpg) no-repeat left 3px;padding:3px 0 3px 15px;}
/*地圖分類*/
.RightPart .Category li{font-size:16px;font-weight:bold;background:url(../images/page_story_icon_ball.jpg) no-repeat left 5px;margin:4px 0 4px 10px;
.RightPart .Category .Line{background:left top;padding:0;margin:0 0 0 3px !Important;margin:-13px 0 0 3px;width:auto;height:4px;} 分類的就是「/*地圖分類的就是「/*地圖分類*/”下面兩行的CSS效果。
把「/*地圖分類*/」的註解去除了,結果F5一下居然發現頁面正常了 看來之前遇到的問題也是一樣啊。
方案總結如果在.net加程式碼的時候發現定義CSS樣式效果遺失,在確定沒有其它問題的情況下試著刪除一些遺失樣式附近的CSS註釋,就可以解決問題。