【问题标题】:Override in child page content and style of nav from master从主页面覆盖子页面内容和导航样式
【发布时间】:2016-06-24 16:26:48
【问题描述】:

您知道有一种方法可以完全清除母版页中的<nav class="navClass">,或者用<nav> (no content, no styling in between) </nav> 替换它吗? 我试过了

<style>
    .navClass { width: 0px !important; }
</style>

这仅对样式生效,但如果我在两者之间有文本,它将不会被删除。

我已经在 c# 中通过在母版页上设置条件解决了这个问题。

<% if ( // condition to not apply for child of certain type { %> //here, original definition with content and style <% } %>

但我想知道是否有更有效的方法可以直接用于子级删除nav,在c# 或css 中,避免使用javascript。 也许我可以在 master 中为它分配 ID 并用它在 child 中覆盖它? 谢谢!

【问题讨论】:

    标签: c# css


    【解决方案1】:

    我通过此链接找到了解决方案。检查是否有用Access an HTML control on ASP Master Page from the code behind of a Content Page

    【讨论】:

      【解决方案2】:

      您可以做的一种方法是通过 jQuery 删除 nav 元素的类。

      下面的代码将删除 nav 的所有关联类。

      $(document).ready(function(){
          $('nav').removeClass();
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-21
        相关资源
        最近更新 更多