我正在为我的angularjs项目编写代码,其中UI的一部分包含卡片。因此,我想通过单击卡片图像来打开模式框。目前,我在图像下方创建了一个按钮,单击该按钮将打开模式框。一切正常。但是我不想点击按钮,而是点击卡片图像,它应该打开模式框。我在下面附加了当前代码。关于此的任何帮助将是非常可观的。谢谢
<div class="col-md-4 clearfix d-none d-md-block">
<div class="card mb-2">
<div class="avatar-wrapper">
<img class="profile-pic" src="/assets/images/abc.jpg" />
<div class="upload-button">
</div>
</div>
<div class="card-body">
<h4> <button type="button" class="card-title text-center font-weight-bold" data-toggle="modal" data-target="#basicExampleModal3">
abc receipe </button> </h4>
<h3 class="description">This is short description in the card body.hio dvdjvd sscg sdgscsc sgssd sdjg c edsc sdcfsc dfkopseuccs sc</h3 >
<div class= "modal fade" id="basicExampleModal3" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel3"
aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel3">Receipe-abc by dfgr</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body ">
<img class="profile-pic" src="/assets/images/abc.jpg" />
<p> Modal Box Description.
sdc
dfvdv
sscg sdgscsc dfvfd
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
将data-toggle="modal" data-target="#basicExampleModal3"
添加到图像元素,例如<img class="profile-pic" src="/assets/images/abc.jpg" data-toggle="modal" data-target="#basicExampleModal3"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="col-md-4 clearfix d-md-block">
<div class="card mb-2">
<div class="avatar-wrapper">
<img class="profile-pic" src="/assets/images/abc.jpg" data-toggle="modal" data-target="#basicExampleModal3"/>
<div class="upload-button">
</div>
</div>
<div class="card-body">
<h4> <button type="button" class="card-title text-center font-weight-bold">
abc receipe </button> </h4>
<h3 class="description">This is short description in the card body.hio dvdjvd sscg sdgscsc sgssd sdjg c edsc sdcfsc dfkopseuccs sc</h3 >
<div class= "modal fade" id="basicExampleModal3" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel3"
aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel3">Receipe-abc by dfgr</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body ">
<img class="profile-pic" src="/assets/images/abc.jpg" />
<p> Modal Box Description.
sdc
dfvdv
sscg sdgscsc dfvfd
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>