为什么要在 bootstrap css 中对这一行进行例外处理?
bootstrap css 的起始模板包括以下内联内容:
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
在所有其他代码都位于外部 .css 文件中的情况下,内联包含此样式的实际原因是什么?
The starter template for bootstrap css includes the following inline:
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
What practical reasons are there for including this style in-line, while all the other code is in an external .css file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
内联样式是故意插入到
bootstrap.css
和bootstrap-responsive.css
之间的。将其移动到main.css
(因此在bootstrap-responsive.css
之后)将在调整到较小的窗口时显示黑色菜单栏上方的填充,至少在IE 10 和 Chrome 22。理想情况下,它应该被添加到
bootstrap.css
中,但由于某种原因没有添加。另一种解决方案是将其放入单独的 css 文件中,但这需要下载一个额外的非常小的文件。
在两个
bootstrap*.css
文件之间加载main.css
将使覆盖特定设置变得更加困难。所以我认为这是一个妥协。
The inline style was deliberately inserted between
bootstrap.css
andbootstrap-responsive.css
. Moving it tomain.css
(and so afterbootstrap-responsive.css
) will show the padding above the black menu bar when it adjusts to a smaller window, at least in IE 10 and Chrome 22.Ideally it should have been added to
bootstrap.css
but it wasn't for some reason.Another solution would be to put it in a separate css file but that would require downloading an additional very small file.
Loading
main.css
between the twobootstrap*.css
files would make it more difficult to override specific settings.So I presume it's a compromise.
可能有几种情况,
!important
规则)。由于内联
元素会自动被认为更具体。There could be several cases,
!important
rules). As inline<style>
elements are automatically considered more specific.