gpt4 book ai didi

javascript - 如何垂直居中模态?

转载 作者:太空狗 更新时间:2023-10-29 14:39:12 25 4
gpt4 key购买 nike

我想垂直居中一个模式。我在谷歌上搜索了很多,但没有找到任何有用的东西。这是我的代码:

 function inactive(id, ths) {
$("#confirmation").modal("show");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="modal fade bs-example-modal-sm" id="confirmation" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">Are you sure you want to inactivate it?</h4>
</div>
<div class="modal-body">
<div class="form-group">
<input type="text" class="form-control" name="captcha" id="cval" placeholder="enter captcha">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
<button type="button" class="btn btn-primary" id="yes">Yes</button>
</div>
</div>
</div>
</div>

如何垂直居中?

最佳答案

未测试,但你可以试试这个

.yourElement{
position: relative;
top: 50%;
transform: translateY(-50%);
}

关于javascript - 如何垂直居中模态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40435286/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com