当我尝试在模式对话框标题栏上对齐关闭图标时,它没有对齐。标题栏仅在关闭按钮旁边被触击。它没有进一步发展。我的想法是将关闭图标保留在对话框标题栏中。像这样吗见下文。
但是我越来越像这样。见下文。
请参阅下面的代码。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Modal Example</h2>
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open modal
</button>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title" style=" width: 100%; height: 24%; margin: -16px -17px 0 -16px; padding: 10px 0 8px 0; background-color: #2196f3; border-top-left-radius: 3px; border-top-right-radius: 3px">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
那么我该如何实现呢?欢迎任何想法和建议。
谢谢。
答案 0 :(得分:1)
您<h4>
的风格正在弄乱外观。将其更改为header div
并删除负边距,如下所示:
<div class="modal-header" style=" width: 100%; height: 24%; margin: 0 padding: 10px 0 8px 0; background-color: #2196f3; border-top-left-radius: 3px; border-top-right-radius: 3px">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
答案 1 :(得分:0)
在模式标题中添加填充和背景色。以模式标题将其删除