Bootstrap 3.0 水平折叠 - 在 Chrome 中弹跳 [英] Bootstrap 3.0 Collapse Horizontally - Bounces in Chrome

查看:24
本文介绍了Bootstrap 3.0 水平折叠 - 在 Chrome 中弹跳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照此处的说明 (https://stackoverflow.com/a/18602739/2966090) 操作在 Bootstrap 3.0.2 中水平折叠一个元素.

此方法在 Firefox & 中运行良好Internet Explorer,但在 Chrome 中显示时出现奇怪的反弹.Chrome 在隐藏上也没有任何过渡.

我在这里创建了一个行为测试:http://jsfiddle.net/eT8KH/1/

这是相关代码(也在 jsfiddle 上):

CSS

#demo.width {高度:自动;-webkit-transition:宽度 0.35s 缓和;-moz-transition:宽度 0.35s 缓和;-o-transition:宽度 0.35s 缓和;过渡:宽度 0.35s 缓和;}

HTML

有没有办法解决这个问题?还是 Chrome 中的错误?

解决方案

我能够重现您的问题,但我找到的解决方案与 Chrome 无关.

我发现插件代码中缺少一些 CSS 代码和一个小错误".我已经写了一个 PR 来解决这个问题,请参阅:https://github.com/twbs/bootstrap/pull/15104

演示:http://jsfiddle.net/zu5ftdjx/

要在您当前的代码中解决此问题:

在collapse.js中:第 104 行应该变成 this.$element[dimension](this.$element[dimension]())[0][$.camelCase(['inner', dimension].join(''))]

less(在 component-animations.less 中)

.collapsing {位置:相对;高度:0;溢出:隐藏;.transition-property(~"高度,可见性");&.width {.transition-property(~"宽度,可见性");宽度:0;高度:自动;}.transition-duration(.35s);.transition-timing-function(ease);}

css(前面 Less 代码的编译输出)

.collapsing {位置:相对;高度:0;溢出:隐藏;-webkit-transition-property:高度、可见性;过渡属性:高度,可见性;-webkit-transition-duration: 0.35s;过渡持续时间:0.35s;-webkit-transition-timing-function:轻松;过渡计时功能:轻松;}.collapsing.width {-webkit-transition-property:宽度、可见性;过渡属性:宽度,可见性;宽度:0;高度:自动;}

I'm following the instructions here (https://stackoverflow.com/a/18602739/2966090) to collapse an element horizontally in Bootstrap 3.0.2.

This method works fine in Firefox & Internet Explorer, but has a strange bounce on show in Chrome. Chrome also doesn't have any transition on hide.

I'm created a test with the behavior here: http://jsfiddle.net/eT8KH/1/

Here's the related code (also on jsfiddle):

CSS

#demo.width {
    height: auto;
    -webkit-transition: width 0.35s ease;
    -moz-transition: width 0.35s ease;
    -o-transition: width 0.35s ease;
    transition: width 0.35s ease;
}

HTML

<button type="button" class="btn btn-primary" data-toggle="collapse" data-target="#demo">
    Horizontal Collapsible
</button>

<div id="container" style="width:200px;">
    <div id="demo" class="collapse in width" style="background-color:yellow;">
        <div style="padding: 20px; overflow:hidden; width:200px;">
            Here is my content
        </div>
    </div>
</div>

Is there a way to fix this? Or is it a bug in Chrome?

解决方案

I was able to reproduce your problem, but the solution i found is not Chrome related.

I found some CSS code was missing and a little 'bug' in the plugin code. I have already wrote a PR to fix that, see: https://github.com/twbs/bootstrap/pull/15104

Demo: http://jsfiddle.net/zu5ftdjx/

To fix this issue in your current code:

in collapse.js: line 104 should become this.$element[dimension](this.$element[dimension]())[0][$.camelCase(['inner', dimension].join(''))]

less (in component-animations.less)

.collapsing {
  position: relative;
  height: 0;
  overflow: hidden;
  .transition-property(~"height, visibility");
  &.width {
  .transition-property(~"width, visibility");
  width:0;
  height:auto;
  }
  .transition-duration(.35s);
  .transition-timing-function(ease);
}

css (compiled output of the preceding Less code)

.collapsing {
  position: relative;
  height: 0;
  overflow: hidden;
  -webkit-transition-property: height, visibility;
  transition-property: height, visibility;
  -webkit-transition-duration: 0.35s;
  transition-duration: 0.35s;
  -webkit-transition-timing-function: ease;
  transition-timing-function: ease;
}
.collapsing.width {
  -webkit-transition-property: width, visibility;
  transition-property: width, visibility;
  width: 0;
  height: auto;
}

这篇关于Bootstrap 3.0 水平折叠 - 在 Chrome 中弹跳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆