css 变换导致 chrome 中的模态闪烁

css transform causes flicker on modal in chrome

我已经使用 semantic-ui 创建了一个模态。当我点击一个按钮时,模态打开。 我修改了模态的 css 属性如下:

#modal {
  width: 400px !important;
  transform: translate(50%, -50%) !important;  
  right: 50% !important;
  left: auto !important;
  top: 50% !important;
  margin: auto !important;
  position: fixed;
}

当我单击 chrome 或边缘浏览器上的按钮时,模式打开,几秒钟后它跳转到一个新位置。 Firefox 没有显示这个问题。
另外,如果我删除 transform: translate(50%, -50%) !important;线,我没有看到问题

你可以在这个代码笔中看到问题: http://codepen.io/masoudhosseini/pen/rjjpbd

终于我找到了问题,我需要禁用模态上的动画才能在 chrome 和边缘中正确显示:

$("#btn").click(function(e){
    e.preventDefault();
    $("#modal").modal({
        blurring: true,
        duration: 0
    }).modal('show');
});

使用了这个 css 和 js

`$("#btn").click(function(e){
e.preventDefault();
$("#modal").modal({
    blurring: true,

}).modal('show');`

var modaleheight = $("#modal").height(); $("#modal").css('margin-top', -(modaleheight/2) ); });

#modal {width: 400px !important; right: 0 !important; left: 0 !important; top: 50% !important; margin: auto; position: fixed;}