HTML5 样板的缺点
我已经使用 XHTML 大约 3 年了,并不太关心 HTML5 和 CSS3 的到来。几个月前,我偶然发现了 HTML5 Boilerplate,现在我开始对它非常感兴趣。
我唯一找不到的是使用这套最佳实践的缺点。我知道,它的主要目标是使网站在各种浏览器上看起来都相同,但是有什么我应该注意的吗?
I've been using XHTML for about 3 years now, and didn't care much about HTML5 and CSS3 arrival. Several months ago I've stumbled upon HTML5 Boilerplate and I'm starting to get very interested in it right now.
The only thing I can't find yet is drawbacks of using this set of best practices. I know, that the main goal of it to make site look the same on wide variety of browsers, but is there something I should be aware about?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,绝对是。 这不是即插即用的东西。或者至少,它可能是这样的,但还没有为此而构思。如果你这样使用它,你就无法享受它的最佳效果。样板非常灵活,您必须学习如何自定义它。句号。
我个人的建议是开始尝试它并研究它所提供的功能。对我们来说幸运的是,它有详细的文档记录,您可以学到很多东西。不仅是样板本身,还包括有关 HTML5、CSS3、资源加载的规则和最佳实践以及性能相关问题/解决方法、浏览器怪癖及其修复方法、移动开发技巧、polyfills 和条件加载以及许多其他内容疯狂的东西。一旦您意识到它的可能性,如果您发现缺点,您将能够自定义基本样板。
从此处开始,阅读文档,遵循每个链接,不要试图走捷径。这需要时间,但你会得到很好的回报。如果您有困难,请询问。
对于更具体的东西,我很快发现的一个缺点(但有人认为这是一个优点)是样板不提供 CSS 网格。不是一个大问题,我发现 adapt.js 很容易集成,所以我用适应替换了 normalize.css .js 重置样式表并使用网格。
Yes, definitely. It's not a plug-and-play thing. Or at least, it could be like that but it hasn't been conceived for that. And if you use it this way you can't enjoy its best. Boilerplate is very flexible and you have to learn how to customize it. Full stop.
My personal suggestion is to start experimenting with it and study the features it has to offer. Luckily for us it's well documented and you can learn a lot. Not only the boilerplate itself, but also the rules and best practices about HTML5, CSS3, resources loading and related issues/workarounds on performances, browsers quirks and how to fix them, tricks for mobile development, polyfills and conditional loading and a lot of other crazy stuffs. Once you are aware of its possibilities, if you'll find drawbacks you'll be able to customize the base boilerplate.
Start from here, read the docs, follow every link and don't be tempted to take shortcuts. It takes time, but you'll be rewarder very well. If you have troubles ask.
For something more concrete, a drawback I found very quickly (but someone consider this a plus) is that the boilerplate doesn't provide a CSS grid. Not a huge problem, I discovered that adapt.js is easily integrable, so I replaced normalize.css with adapt.js's reset stylesheet and used the grid.
几个月前我注意到的两件事是 JavaScript 在正文底部加载的方式。我不太喜欢这个,因为它不仅看起来很脏。我自己也测试了加载,没有发现 javascript 的加载有任何更好的效果。事实上,它在一个巨大的脚本上运行速度慢了几毫秒。
另外,我尝试了几次 normalize.css,但发现自己重新设计了比以前更多的填充和边距。这当然很正常,因为它的目标有些相似,但方法不同。我将其更改为 Eric Meyer 的 reset.css 只是因为我已经习惯了。
我真的很喜欢 Modernizr 脚本以及实现 x 浏览器结果的方法。
以 Google Analytics 实施为例。
我记得的另一件小事是标题标签的放置。出于 SEO 的原因,我将其更改为顶部位置。
Two things I noticed couple months back is the way javascript gets loaded at the bottom of the body. I'm not a big fan of this if not only it looks dirty. Also I tested the loading myself and didn't notice any better loading of javascript. In fact it ran a couple ms slower on a huge script.
Also the normalize.css I tried couple of times but found myself restyling more paddings and margins than before. Which is normal ofcourse since it's goal is somewhat similar but a different approach. I changed this to Eric Meyer's reset.css just because I'm used to it.
I really like the modernizr script and the way to implement things for x-browser results.
Google Analytics implementation for example.
Another small thing I remember was the placing of the title tag. I changed it to the top position for SEO reasons.