c# - html.ActionLink 使用类将 Logo 与 CSS 放在一起, Logo 永远不会出现

标签 c# html css asp.net-mvc

我正在尝试使用 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/

相关文章:

c# - 处理异常,这是一个好方法吗?

c# - Asp.net MVC2 - 表单后绑定(bind)

javascript - 是否有允许您在同一个文件中编辑 HTML、CSS 和 Javascript 的模板系统?

Javascript延迟for内的图像更改

javascript - 为什么简单的幻灯片放映不起作用?

css - 如何单独设置 Angular Material 组件的样式?

c# - 如何在 ASP MVC 中将数据传递到共享 View ?

c# - 如果我运行一个需要 5 分钟才能完成的存储过程,我的代码序列会在存储过程完成之前继续吗?

css - SCSS 到 CSS 错误,Prepros 无法提供 CSS

html - 在导航栏上工作并遇到 CSS 文件集成问题