【问题标题】:Bootstrap3 migration failedBootstrap3 迁移失败
【发布时间】:2013-08-29 00:51:50
【问题描述】:

我正在使用此代码在我的网站上创建标尺:

CSS:

.ruler, .ruler li {
    margin: 0;
    padding: 0;
    list-style: none;
    display: inline-block;
}
/* IE6-7 Fix */
.ruler, .ruler li {
    *display: inline;
}
.ruler {
    background: lightYellow;
    box-shadow: 0 -1px 1em hsl(60, 60%, 84%) inset;
    border-radius: 2px;
    border: 1px solid #ccc;
    color: #ccc;
    margin: 0;
    height: 3em;
    padding-right: 1cm;
    white-space: nowrap;
}
.ruler li {
    padding-left: 1cm;
    width: 2em;
    margin: .64em -1em -.64em;
    text-align: center;
    position: relative;
    text-shadow: 1px 1px hsl(60, 60%, 84%);
}
.ruler li:before {
    content: '';
    position: absolute;
    border-left: 1px solid #ccc;
    height: .64em;
    top: -.64em;
    right: 1em;
}

/* Make me pretty! */
body {
    font: 12px Ubuntu, Arial, sans-serif;
    margin: 20px;
}

div {
    margin-top: 2em;
}

HTML:

<ul class="ruler"><li>1</li><li>2</li><li>3</li><li>4</li></ul>

使用 bootstrap2 可以正常工作:

http://jsfiddle.net/Uvt5U/4/

现在我正在迁移到 bootstrap3 并且标尺坏了:

http://jsfiddle.net/Uvt5U/

我怎样才能让它工作? 亲切的问候。

【问题讨论】:

  • 这与引导程序有什么关系,标尺不是引导程序类...
  • @Patsy Issa,大多数标签都有默认样式。 @author,我发现如果将.ruler liwidth 增加到1,64cm,它就可以工作。这不是答案,而是提示。 :)
  • @dragoste 不是 ul 标签。
  • @Patsy Issa,看看我的回答。 * 也表示 &lt;ul&gt; ;)
  • @dragoste 不错的收获!

标签: css twitter-bootstrap-3


【解决方案1】:

这是因为在 Bootstrap 3 中 box-sizing 样式设置为 border-box,而在 Bootstrap 2 中则没有。

我的 Firebug 指出这条规则正在设置这种风格:

*, *:before, *:after {
    -moz-box-sizing: border-box;
}

bootstrap.min.css 第 9 行

【讨论】:

猜你喜欢
  • 2016-02-16
  • 2018-08-27
  • 2020-05-29
  • 2015-01-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多