【问题标题】:Sticky footer Orchard CMS粘性页脚果园 CMS
【发布时间】:2013-02-19 03:09:54
【问题描述】:

我正在尝试应用粘性页脚,但在 Orchard 中实现此功能时遇到问题。

在以前的网站中,我成功应用了以下粘性页脚方法: http://www.cssstickyfooter.com/using-sticky-footer-code.html

我只是无法在 Orchard 中使用粘性页脚,也找不到任何相关信息。

已经尝试删除所有现有的 CSS 以尝试找出其无法正常工作的原因。使用 firebug 检查 HTML 时也不会变得更明智。

使用的模板:基于自定义主题的主题机(结构不变)。

问题:

site.css 中的区域填充导致了这些奇怪的问题。但是我怎样才能保留这个填充,这样我就可以实现一个粘性页脚?

因为没有区域填充,所有区域的所有必要填充都消失了。

/* Zones */
.zone 
{
    padding: 10px;
}

或者还有其他更适合 Orchard 的方法来实现粘性页脚吗?

旁注问题

@tag.StartElement 和@tag.EndElement 的用途究竟是什么?

CSS: (我的页脚高度正好是 40px)

html, body
{
  height: 100%;
}

#layout-wrapper { min-height: 100%; }

#layout-footer 
{
    position: relative;
    margin-top: -40px; /* negative value of footer height */
    clear:both;
    background-color: #030e27;
}

Layout.cshmtl:

@tag.StartElement
@if (Model.Header != null) 
{
    <header>
        <div id="layout-header" class="group">
            <div id="header">
                @Zone(Model.Header)
            </div>
        </div>
        <div id="layout-header-bottom"></div>
    </header>   

}

@if (Model.Navigation != null) 
{
    <div id="layout-navigation" class="group">
        <div id="navigation">
            @Zone(Model.Navigation)
        </div>
    </div>
}


@if (Model.Featured != null) {
<div id="layout-featured" class="group">
    @Zone(Model.Featured)
</div>
}
@if (Model.BeforeMain != null) {
<div id="layout-before-main" class="group">
    @Zone(Model.BeforeMain)
</div>
}

<div id="layout-main-container">
<div id="layout-main" class="group">
    @if (Model.AsideFirst != null) {
    <aside id="aside-first" class="aside-first group">
        @Zone(Model.AsideFirst)
    </aside>
    }
    <div id="layout-content" class="group">
        @if (Model.Messages != null) {
        <div id="messages">
            @Zone(Model.Messages)
        </div>
        }
        @if (Model.BeforeContent != null) {
        <div id="before-content">
            @Zone(Model.BeforeContent)
        </div>
        }
        @* the model content for the page is in the Content zone @ the default position (nothing, zero, zilch) *@
        @if (Model.Content != null) {
        <div id="content" class="group">
            @Zone(Model.Content)
        </div>
        }
        @if (Model.AfterContent != null) {
        <div id="after-content">
            @Zone(Model.AfterContent)
        </div>
        }
    </div>
    @if (Model.AsideSecond != null) {
    <aside id="aside-second" class="aside-second">
        @Zone(Model.AsideSecond)
    </aside>
    }
</div>
</div>

@if (Model.AfterMain != null) {
<div id="layout-after-main" class="group">
    @Zone(Model.AfterMain)
</div>
}
@if (Model.TripelFirst != null || Model.TripelSecond != null || Model.TripelThird != null) {
<div id="layout-tripel-container">
<div id="layout-tripel" class="group">@* as in beer *@
    @if (Model.TripelFirst != null) {
    <div id="tripel-first">
        @Zone(Model.TripelFirst)
    </div>
    }
    @if (Model.TripelSecond != null) {
    <div id="tripel-second">
        @Zone(Model.TripelSecond)
    </div>
    }
    @if (Model.TripelThird != null) {
    <div id="tripel-third">
        @Zone(Model.TripelThird)
    </div>
    }
</div>
</div>
}
@tag.EndElement
<div id="layout-footer" class="group">
    <footer id="footer">
        <div id="footer-quad" class="group">
            @if (Model.FooterQuadFirst != null) {
            <div id="footer-quad-first">
                @Zone(Model.FooterQuadFirst)
            </div>
            }
            @if (Model.FooterQuadSecond != null) {
            <div id="footer-quad-second">
                @Zone(Model.FooterQuadSecond)
            </div>
            }
            @if (Model.FooterQuadThird != null) {
            <div id="footer-quad-third">
                @Zone(Model.FooterQuadThird)
            </div>
            }
            @if (Model.FooterQuadFourth != null) {
            <div id="footer-quad-fourth">
                @Zone(Model.FooterQuadFourth)
            </div>
            }
        </div>
        @if(Model.Footer != null) {
        <div id="footer-sig" class="group">
            @Zone(Model.Footer)
        </div>
        }
    </footer>
</div>

更新

Derk 的解决方案与删除以下 Orchard CSS 相结合似乎起到了作用:

/* Clearing Floats
***************************************************************/

.group:after 
{
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}


.zone:after, .widget-control:after /* .zone:after self clears every zone container - .widget-control:after self clears any floats used in a widget */
{
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}

更新 2

而不是删除清除浮动 css changing content: "."content: "" 似乎也具有相同的效果。

对此原因的解释将不胜感激,干杯。

问候, 泽。

【问题讨论】:

  • 我在 html 中没有看到您的 css 引用的#wrapper。
  • 包装器由 Orchard 框架创建。
  • 你能控制吗?或者如果没有,你能不能再做一个你可以控制的?在您的代码中,没有任何内容可以指定缓冲区。你没有所有的碎片。 d
  • 你好 Derek,我可以删除 @tag 以便删除布局包装器并添加我自己的 div 包装器(如果你是这个意思)。
  • Orchard 只是一个 CMS。它将您的内容推送到 div 中。在果园中没有一种方法可以做到这一点......只有在 HTML 和 CSS 中做到这一点的方法就是果园 - 除了动态调用要放入这些 div 的信息。

标签: html css orchardcms


【解决方案1】:

对于该填充问题,我建议您查看此边框框方法。它将填充移动到 div 内部而不是外部。所以你不必在整个项目中计算填充和 div 宽度等。太有用了!

/* apply a natural box layout model to all elements */
* { 
    -moz-box-sizing: border-box; 
    -webkit-box-sizing: border-box; 
    box-sizing: border-box; 
}

只需将它放在样式的顶部即可!可能需要进行一些调整才能使网站恢复原状,但这是值得的。

但现在:将其添加到您的 .zone 事物中:

.zone {
    -moz-box-sizing: border-box; 
    -webkit-box-sizing: border-box; 
    box-sizing: border-box;
    padding: 10px;
}

您可以在此处阅读更多相关信息:Paul Irish talks about border-box

对于页脚:

看看这支笔:Weighted Footer

您的代码中已经包含 html 和 body - 但是您有某种包装器吗?

如果没有,则需要放入:

<div class="main-wrapper">

    <header></header>

    <section class="main-content"></section>

    <div class="footer-buffer">(BUFFER)</div>

</div> <!-- end .main-wrapper -->

<footer></footer>

非常基本的结构在这里。因此,请检查它或您的主题中是否存在类似的东西。

html, body {
  height: 100%;
}

.main-wrapper {
  min-height: 100%;
  height: auto !important; /* for IE 6 */
  height: 100%; /* for IE 6 */
  margin: 0 auto -4em;

  /* new addition */
  overflow: hidden;
}

footer, .footer-buffer {
  height: 4em;
}

我个人会将width: 100%;float: left; 放在所有这些上...但是您需要使其尽可能简单以找出问题所在。然后,您可能需要在每个部分中添加另一个 div,例如 .inner {max-width: 980px; margin: 0 auto;},以使该标准列网站看起来。我会备份你的 CSS 文件并像你一样做更多的测试。

希望对您有所帮助!我花了这么多小时和一天的时间来对抗那个粘页脚!

【讨论】:

  • 您发现您遇到的填充问题了吗?
  • 大约一年前,我连续两天对大约 10 个项目感到抓狂。每次我都想通了——但这太糟糕了,而且我每次都想不通。这就是为什么我花了很多时间在选项上并得出我提供的笔的结论。有很多事情正在发生......但如果你能缩小范围并让基本的 4 件事发挥作用,它就会起作用。可能有一些你不知道的风格让你感到困惑。尝试将您的样式放在这部分样式表的末尾。作为测试。现在尽可能简化。
  • 为什么它只适用于 4em?当我尝试将其更改为 px 或其他 em 时,它根本不起作用?当我使用 4em 时它删除了滚动条,但当我使用例如 2em 时它不起作用。谢谢。
  • 呃...在我的情况下,我的重置将正文字体设置为 62.5%,这使得标准字体大小为 10px,转换为 1em。所以 4em 是 40 px,(在我的情况下) - 你必须确保在包装器的 -margin 以及页脚和页脚缓冲区上设置它的任何数字(40px 或其他)。 - 这三件事必须相等。
  • 不太确定我在那儿跟着你 Derek :)。我的字体大小设置为 100%。当我有 4 个 em(主包装页脚和缓冲区)时,当我更改值时,滚动条再次出现并且一切都变得混乱。我们非常接近,但这完全让我困惑为什么只有 1 个值有效!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-03
  • 1970-01-01
  • 2011-07-26
  • 2013-02-23
  • 2011-07-25
  • 1970-01-01
  • 2011-09-23
相关资源
最近更新 更多