5

MVC (4) を使用した Razor 構文に苦労しています。うまく機能するソリューションを手伝ってくれる人を見つけたいと思っています。

クリック可能なロゴ(画像)が必要で、次のコードを作成しました。これは2つのことを除いて機能します。画像が表示されず、次に、別のコントローラーでルーティングがうまくいかない (http4 エラー)。

これは私が今それをやった方法です:

かみそり:

<h1>@Html.ActionLink("siteHeader", "Index", null, new { @class = "site-logo"})</h1>

また

<h1>@Html.ActionLink("siteHeader", "Index", "Home", new { @class = "site-logo"})</h1>

たとえば、別のコントローラー (アカウント/ショッピングカートなど) でロゴをクリックすると、404 が発生します。

CSS:

/サイトヘッダーロゴ/

a.site-logo  {     
 background: url(images/Solosoft.png) no-repeat top left;
 display: block;       
 width: 100px;       
 height: 100px;       
 text-indent: -9999px;  /*hides the link text*/ 
  } 

前もって感謝します。

4

3 に答える 3

2

これを試して:

@Html.ActionLink("siteHeader", "Index", "Home", null, new { @class = "site-logo"})

これは:

public static MvcHtmlString ActionLink(
    this HtmlHelper htmlHelper,
    string linkText,
    string actionName,
    string controllerName,
    Object routeValues,
    Object htmlAttributes
)

リンク: msdn

于 2012-10-02T13:16:48.143 に答える
1

問題の原因がわかりました!

コーディングに問題はありません。画像セットをオーバーライドするクラスがあります。

Site.cssにこの行があります

.site-title a, .site-title a:hover, .site-title a:active {
    *background: none;* <=comment this out and the bg will show or remove the .site-title a
    color: #c8c8c8;
    outline: none;
    text-decoration: none;
}

それが役に立てば幸い

于 2013-04-04T08:14:05.860 に答える
0

ウィザーズの言ったことは正しい。カスタム css ファイルの背景スタイルは、site.css のスタイルによって上書きされます。

これを試してください!important- Web ページに表示されるスタイルを優先するために使用されます。

custom.css ページで、

a.site-logo  {     
     background: url(images/Solosoft.png) no-repeat top left **!important**;
     display: block;       
     width: 100px;    
     height: 100px;       
     text-indent: -9999px;  /*hides the link text*/ 
} 

site.css を変更する必要はありません

于 2013-06-27T13:08:36.403 に答える