twitter-bootstrap 在生产中使用 Bootstrap 是不好的做法吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28052366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 22:11:03  来源:igfitidea点击:

Is it bad practice to use Bootstrap in production?

htmlcsstwitter-bootstrap

提问by an earwig

I have often used Bootstrap to design my UI. It provides an easy and powerful way to keep from reimplementing UI components such as nav-bars and modals. I recently came into contact with another developer who said that he does not use Bootstrap for production sites. He says the creating your own UI is better. I also read a book saying that bootstrap is good for prototypingUI. Is is considered a bad practice to use these predefined UI's when developing sites??

我经常使用 Bootstrap 来设计我的 UI。它提供了一种简单而强大的方法来避免重新实现 UI 组件,例如导航栏和模式。我最近接触到另一位开发人员,他说他不将 Bootstrap 用于生产站点。他说创建自己的用户界面更好。我还读过一本书,说引导程序适用于UI原型设计。在开发网站时使用这些预定义的 UI 被认为是一种不好的做法吗?

回答by Eugene

It entirely depends on your unique UX needs. I like bootstrap for rapid prototyping proofs of concept. But I agree to previously mentioned, if you need a snowflake bootstrap will only hinder you workflow and overall maintenance. Use prudently.

这完全取决于您独特的用户体验需求。我喜欢 Bootstrap 用于快速原型设计概念证明。但我同意前面提到的,如果你需要一个雪花引导程序只会阻碍你的工作流程和整体维护。谨慎使用。

Also, some will say that it does not make sense to reinvent the wheel. Sure, but not all UI are wheels.

此外,有些人会说重新发明轮子没有意义。当然,但并非所有 UI 都是轮子。

回答by Chuck Le Butt

Your friend is right. Bootstrap is great for quickly putting together a website for internal use or rapid prototyping, but unless you're using its features (e.g. its styles, components, etc.) it is probably unnecessary. Personally I would never use it in production for a website with an intended long lifespan (unless the default look worked and wasn't going to change -- eg. a CMS or admin section).

你的朋友是对的。Bootstrap 非常适合快速组合网站以供内部使用或快速原型制作,但除非您正在使用其功能(例如,其样式、组件等),否则它可能是不必要的。就我个人而言,我永远不会在具有预期长寿命的网站的生产中使用它(除非默认外观有效并且不会改变 - 例如 CMS 或管理部分)。

Bootstrap's way of doing things means fast development, but it's not very efficient. You're getting 150kb of styles out the gate, and you may only be using a tiny portion of them.

Bootstrap 的做事方式意味着快速开发,但效率不高。您将获得 150kb 的样式,而您可能只使用其中的一小部分。

Strangely you will see people claim that it's great for public facing sites, and point to the notion that it grew out of Twitter.com's public website. This isn't true. Bootstrap was only ever designed for (and used by) Twitter's internal tools. And really that type of project is what it remains best at.

奇怪的是,您会看到人们声称它非常适合面向公众的网站,并指出它源自 Twitter.com 的公共网站。这不是真的。Bootstrap 只是为 Twitter 的内部工具设计(并由其使用)。事实上,这种类型的项目才是它最擅长的。

So if the site you're building has a short lifespan (and so won't be changed much), or is OK to look close to the default look (eg. an admin interface), it can be great. (And if all you want is a grid system, you certainly don't need Bootstrap's 121kb CSS file just for that, especially now CSS grids are more widely supported.)

因此,如果您正在构建的站点生命周期较短(因此不会有太大变化),或者可以接近默认外观(例如管理界面),那么它可能很棒。(如果你只想要一个网格系统,你当然不需要 Bootstrap 的 121kb CSS 文件,尤其是现在CSS 网格得到更广泛的支持。)

Tim G. Thomas's breakdown of Bootstrap's strengths and weaknesses remains worth watching, too: https://vimeo.com/68331927(starts at 17 minutes in, but the whole presentation is great).

Tim G. Thomas 对 Bootstrap 优势和劣势的细分仍然值得一看:https: //vimeo.com/68331927(从 17 分钟开始,但整个演示文稿很棒)。

回答by Stokely

I would not use Bootstrap for even prototyping. Its full of bad assumptions about how websites should use CSS.

我什至不会将 Bootstrap 用于原型设计。它充满了关于网站应该如何使用 CSS 的错误假设。

For starters it uses pixel-based layouts and font-sizing which is the NUMBER ONE mistake every CSS person should avoid. (Use EM or percentages, Points for print). It also assigns margins inside containers which spells trouble if you are using pixel units on parents. You will often see Bootstrap layouts breaking through floats and parent divs because of that. Finally, it assumes that websites should be "gridded" then managed via floats which is unnecessary. By locking widths into pixel dimensions and then floating pixel unit layouts, you break the whole purpose of structure-content separation. The structure, layout and look of an application with bootstrap is more important than the flow of content. The user can no longer size fonts and text when they use pixels, and view of such layouts now is heavily dependent on zoom and float features now rather than expandable content/text blocks where the user's font size selections grow based on the user's viewport and device.

对于初学者来说,它使用基于像素的布局和字体大小,这是每个 CSS 人都应该避免的第一个错误。(使用 EM 或百分比,打印点)。它还在容器内分配边距,如果您在父级上使用像素单位,这会带来麻烦。因此,您经常会看到 Bootstrap 布局突破浮动和父 div。最后,它假设网站应该被“网格化”,然后通过浮动进行管理,这是不必要的。通过将宽度锁定为像素尺寸,然后浮动像素单元布局,您打破了结构-内容分离的全部目的。具有引导程序的应用程序的结构、布局和外观比内容流更重要。用户在使用像素时不能再调整字体和文本的大小,

Bootstrap in that sense goes back to an OLDER 1999 view of the web and CSS by embracing the outdated visual priority of building web structures rather than the newer "content-is-king" view we developed using Web Standards and "scalable", text-based layouts after 2001. If they had reviewed the history they would have understood why CSS and websites changed in how text was displayed and how cross-browser decisions used to be made.

从这个意义上说,Bootstrap 通过拥抱构建 Web 结构的过时视觉优先级,而不是我们使用 Web 标准和“可扩展”文本开发的较新的“内容为王”视图,可以追溯到 1999 年的 Web 和 CSS 视图。基于 2001 年之后的布局。如果他们回顾了历史,他们就会理解为什么 CSS 和网站在文本显示方式以及过去如何做出跨浏览器决策方面发生了变化。

In that sense Bootstrap reinvented the wheel alright, created a square one when the round one was working just fine. :)

从这个意义上说,Bootstrap 重新发明了轮子,当圆形工作正常时创建了一个方形。:)

回答by Jona

I agree with the others that using Bootstrap to prototype ideas is great, but that Bootstrap should never be used as a final product (except if you're designing an admin interface).

我同意其他人的观点,即使用 Bootstrap 来构建创意原型很棒,但永远不应将 Bootstrap 用作最终产品(除非您正在设计管理界面)。

Not only does Bootstrap not teach you a lot, when you don't put much thought into redesigning it - which can be a problem - everyone will instantly notice that the site was made on the Bootstrap framework which will make them question the professionality of your website.

Bootstrap 不仅没有教给你很多东西,当你不去重新设计它时——这可能是一个问题——每个人都会立即注意到这个网站是在 Bootstrap 框架上制作的,这会让他们质疑你的专业性网站。

Again: Bootstrap is great for quick prototyping, but in order to create a professional, easily debuggable site of which you (very important!) know the code and know what every single piece of code does I don't recommend using Bootstrap.

再次强调:Bootstrap 非常适合快速原型设计,但为了创建一个专业的、易于调试的站点,您(非常重要!)了解代码并了解每段代码的内容,我不建议使用 Bootstrap。