为什么 HTML5 不强制执行“粘性”?页脚标签
我目前正在摆弄“粘性”页脚,并遇到了问题中引用的常用链接:为什么不使用position:fixed作为“粘性”页脚?
虽然我很高兴这些修复的存在,但我很好奇为什么页脚问题在重新设计中没有得到解决HTML5 的精神。撇开语义问题不谈,网络文档作者会期望页脚具有默认行为,即成为“粘性页脚”:停留在页面底部,除非页面内容较长。
我觉得这是一个消除大量黑客行为的错失机会,并且想知道不为页脚标签分配“粘性”行为的考虑因素是什么。
I am currently fiddling around with 'sticky' footers, and have come across the usual links as referenced in Q: Why not used position:fixed for a "sticky" footer?
While I'm happy that these fixes exist, I am curious to find out why the footer issue was not addressed in the reengineering spirit of HTML5. Semantic issues aside, an web document author would expect a footer to have a default behaviour, i.e, be a 'sticky footer' : stay at the bottom of the page, unless the page contents are longer.
I feel this is a missed opportunity to do away with a lot of hacks, and would like to know what were the considerations in not assigning a 'sticky' behaviour to the footer tag.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTML5 没有定义 HTML 的布局。这就是 CSS 的工作。
我不确定 CSS 是否考虑过像您所描述的布局,所以我不确定其优点和缺点是什么。
CSS 布局通常不允许通过
position:fixed;
以外的方式引用浏览器窗口,而 Internet Explorer 在版本 6 中不支持这种方式,因此我认为实现此类布局存在一些挑战能力。不过,我很想听听任何了解一些细节的人的意见。此外,
HTML5 doesn’t define the layout of HTML. That’s CSS’s job.
I’m not sure if a layout like you’ve described has ever been considered for CSS, so I’m not sure what the pros and cons would be.
CSS layouts don’t generally allow any reference to the browser window other than via
position: fixed;
, which Internet Explorer didn’t support in version 6, so I presume there are challenges involved in implementing such layout capabilities. I’d love to hear from anyone who knows some specifics though.Also,
<footer>
s aren’t necessarily footers for the entire page — they can just be footers for a<section>
or similar. You wouldn’t want all of the footers on a page bunched up at the bottom of the page/browser window.