2

我陷入了一个难题。我正在改造 Square Space 网站。我正在使用他们的测试版“开发者”模式;到目前为止,这似乎只允许 CSS 文件的来源,一切都在它们的“”或 . / 。。在任何地方都找不到 .html 或 .php 文件。

所以我被困在他们的“代码注入区域”——以及页脚。我设置了页脚内容,但页脚应该显示在除主页之外的所有地方。我想知道你们中是否有人知道一种方法来编写内联 JS 和/或 CSS 以仅在主页中隐藏页脚;或通过主页网址?

<center>
  <div>
    <a class="footer" href="https://coolguys.squarespace.com/terms/">FAQ</a>&nbsp;•

    <a class="footer" href="https://coolguys.squarespace.com/green/">GREEN</a>&nbsp;•

    <a class="footer"  href="https://coolguys.squarespace.com/wholesale/">WHOLESALE</a>&nbsp;•

    <a class="footer" href="https://manbearpigs.squarespace.com/links/">LINKS</a>

<br>
  <span>Hello World</span>    
</div>

用纯 CSS 来做这件事是最可取的。

我找到了这个:

body.page-id-777 td#footer {
display:none;
}

但不确定页面 URL 等如何;可以转换为页面 ID。

4

2 回答 2

6

使用纯 js 很容易做到这一点。

if (document.url == "http://squarespace.com") {
    document.getElementsByClassName("footer")[0].style.display = 'none';
}
于 2013-12-04T00:34:07.690 回答
1

我可能是错的,但我认为 squarespacehomepage在正文中为主页设置了一个page类,并为每个其他页面设置了一个类。如果是这种情况(我怀疑你可以很容易地测试它),那么下面的 CSS 应该可以工作:

body.homepage td#footer {display: none;}
body.page td#footer {display: table-cell;}
于 2013-12-04T00:47:00.867 回答