引导模态在打开时被禁用

时间:2018-12-01 14:04:36

标签: javascript html css angular5

我在我的角度项目中使用bootstrap 3.3.7,并且通过单击“ ADD CLASS”打开它时禁用了模态。 我的代码在下面。

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<div class="add-class pointer" data-toggle="modal" data-target="#add-class-modal">
  <img alt="+" src="assets/images/add.png" height="16px" width="16px" style="margin-top: -2px"><span class="add-a-class">ADD CLASS</span>
</div>
<!-- Modal -->
<div class="modal fade" id="add-class-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <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" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

结果看起来像这样。 enter image description here

“ ADD CLASS”按钮位于右上角。 我该如何解决?

1 个答案:

答案 0 :(得分:0)

可能您有一些样式,使背景叠加层具有更大的z索引。确保您的模态类具有正确的样式,并且不要再有其他任何形式。它应与默认的引导程序样式配合使用。您可以尝试将更大的z-index设置为.modal,但是关键是要检查是否没有应用其他样式。

[HttpPost]
[Route("InsertData")]
public IActionResult InsertData([FromBody] string FromAddress)
{
    try
    {
         //var fromAddress = Request.Form["FromAddress"].ToString();
        _webHookDb.UserData.Add(new UserData()
        {  
            FromAddress = FromAddress,
            DateTime = DateTime.Now
        });
        _webHookDb.SaveChanges();
        return new JsonResult(FromAddress);
    }
    catch (Exception ex)
    {
        return BadRequest(ex.Message);
    }
}

如果z-index小于1072,则可以用灰色背景覆盖

更新:

基于引导程序页面上的引导程序示例模态,看起来灰色背景是由div创建的,其类为mocal-backdrop,默认情况下具有以下z-index:

// this is class for dialog itself
.modal {
   position: relative;
   z-index: 9999
}