javascript - 删除除主页以外所有页面的公共(public)页眉中的特定元素

标签 javascript html css handlebars.js

我修改了主页标题。但是,我不希望除主页之外的所有其他网页看起来都像主页标题 View 。有没有办法删除 How can we help today? 和搜索栏标题 View ,并在主页以外的每个页面中简单地描绘标题?

Homepage

Header look in every other web page than the homepage

/***** Header *****/
.header {
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 5%;
    position: relative;
    align-items: center;
    display: flex;
    height: 71px;
    justify-content: space-between;
}

@media (min-width: 1160px) {
    .header {
        padding: 0;
        width: 90%;
    }
}

.logo img {
    max-height: 37px;
}

.user-nav {
    display: inline-block;
    position: absolute;
    white-space: nowrap;
}

<section class="section hero">
    <header class="header">
        <div class="logo">
            {{#link 'help_center'}}
            <img src="{{logo_url}}" alt="{{t 'logo'}}">
            {{/link}}
        </div>
        <div class="nav-wrapper">
            <span class="icon-menu"></span>
            <nav class="user-nav" id="user-nav">
                {{link 'new_request' class='submit-a-request'}}
            </nav>
            {{user_info}}
        </div>
    </header>

    <div class="hero-inner">
        <h1 style="color:white;">How can we help today?</h1>
        {{search submit=false instant=true class='search search-full'}}
    </div>
</section>

最佳答案

你能在主页上添加一个类吗?大多数 CMS 都有一个应用于 html 或 body 标签的“is-front”类。所以在css中,你可以做

.header-inner {display:none}
.is-front header-inner {display:block}

关于javascript - 删除除主页以外所有页面的公共(public)页眉中的特定元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54484175/

相关文章:

html - 如何在文本更改时保持图像的位置?

javascript - 是否可以仅使用 html、css 和 javascript 动态创建 div?

javascript - node.bcrypt.js 未更新对象中的密码

javascript - 在 AJAX 请求中重定向到登录页面

javascript - 如何将 html 选择选定值复制并粘贴到其他选择

css - 响应式地垂直和水平居中文本

html - 根据条件在模板中添加中间元素

html - 右上角的日期导致页眉偏心

javascript - 监听 Firebase (AngularFire) 中数据的更改

javascript - 选项卡在 Bootstrap v4.3.1 中不工作,但在 v4.1.0 中工作