我正在尝试使用 CSS 放置 Logo ,但它没有显示出来。 我尝试使用 class=site-title
_Layout.cshtml
<body>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">@Html.ActionLink("your logo here", "Index", "Home")</p>
</div>
<div class="float-right">
<section id="login">
@Html.Partial("_LoginPartial")
</section>
<nav>
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("Categorie", "Index", "Categorie")</li>
<li>@{Html.RenderAction("CartSummary", "Panier");}</li>
CSS
.site-title {
color: #c8c8c8;
font-family: Rockwell, Consolas, "Courier New", Courier, monospace;
font-size: 2.3em;
margin: 0;
}
.site-title a, .site-title a:hover, .site-title a:active {
background: none;
color: #c8c8c8;
outline: none;
text-decoration: none;
}
.site-title {
background: url(../Images/htc_magic_black_open2.jpg) no-repeat top left;
display: block;
width: 150px;
height: 150px;
text-indent: -9999px; /* hides the link text */
}
我也试过这个
<p class="site-title">@Html.ActionLink("your logo here", "Index", "Home", new { @class = "logo"
})</p>
也试过这个
<p class="site-title">@Html.ActionLink("your logo here", "Index", "Home" ,null, new { @class =
"logo" })</p>
CSS 改为
.logo {
background: url(../Images/htc_magic_black_open2.jpg) no-repeat top left;
display: block;
width: 150px;
height: 150px;
text-indent: -9999px; /* hides the link text */
}
但我把 class=site-title 留在了前面。有什么建议吗?
最佳答案
因为我是新注册的,所以我无法添加评论,所以很遗憾,它必须放在“答案”框中...
如果您用完整的 URL(即 http://www.example.com/images/htc_magic_black_open2.jpg)替换相对路径“../Images/htc_magic_black_open2.jpg”,图像会出现吗?这将确定它是否是相对路径问题。
如果您在 .site-title 类中添加“background-color: red”类,该框会变红吗?如果不是,则可能是您的 CSS 没有被应用。
关于c# - html.ActionLink 使用类将 Logo 与 CSS 放在一起, Logo 永远不会出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22179123/