你真的认为居中对齐那么简单那么我们现在升个级,毕竟要打得怪有点难。。。

JS控制DIV居中对齐

<div >否</button>
</div>
</div>

如这个代码弹出的模态框,怎么样让这个中间白色的块居中对齐,代码如下

//获取黑色遮罩层的宽、高
var modelWidth = $('#hz_qxalert1_id').width();
var modelHeight= $('#hz_qxalert1_id').height();

//获取取消会诊确认框的宽、高
var alertWidth = $('#hz_qxalert1_id_next').width();
var alertHeight= $('#hz_qxalert1_id_next').height();

//让取消会诊确认框相对于模态框居中
parent.document.getElementById('hz_qxalert1_id_next').style.left = (modelWidth-alertWidth)/2+"px";
parent.document.getElementById('hz_qxalert1_id_next').style.top = (modelHeight-alertHeight)/2+"px";

//让取消会诊的确认框显示出来
document.getElementById('hz_qxalert1_id_next').style.display = "block";

相关文章:

  • 2021-06-11
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
猜你喜欢
  • 2021-09-17
  • 2022-12-23
  • 2021-11-13
  • 2022-02-23
  • 2022-12-23
  • 2021-11-21
相关资源
相似解决方案