当我试图在模态对话框标题条上对齐关闭图标时,它不会对齐。标题条仅在关闭按钮旁边敲击。它没有进一步发展。我的想法是在对话框标题条上保留关闭图标。像这样的东西?见下文。
但我会这样。见下文。
请参阅下面的代码我尝试过的内容。
<!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>
那我该怎么做呢?欢迎任何想法和建议。
谢谢。
你的<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>
将填充和背景颜色添加到modal-header。将它们移到模态标题中