【发布时间】:2017-03-03 16:23:02
【问题描述】:
我有以下内容 - 现在我只希望在元素具有粘性类的情况下应用主体 - 只是现在因为 @at-root 主体边距始终处于活动状态 - 但我也需要它才能使其在原地工作这个嵌套。
// Sticky
// @todo The body margin is always present even if not sticky
//------------------------------------------------------------------------//
&--sticky {
@at-root {
body {
margin-bottom : 260px;
}
footer#{ & } {
position : absolute;
bottom : 0;
width : 100%;
height : 260px;
background-color : #f5f5f5;
}
}
}
HTML 使用上面的 CSS,总是应用正文边距 - 它不应该是
<footer>
blah
<footer>
选项是
With the above CSS the body margin is applied and the footer postion
<footer class="footer--sticky">
blah
<footer>
我想要一个解决方法,如果粘性类不存在,那么嵌套的 css 将不会运行
任何帮助表示赞赏
【问题讨论】:
-
你期望什么 CSS 代码?您的 HTML 看起来如何?
-
更新了一点 - 这有帮助 - 哈哈,有人已经在没有评论的情况下投了反对票 - 有点苛刻:)