Kyle Chen's Blog

Action speaks louder than Words

0%

Boostrap3 Motal をBoostrap5 Motalにリファクタリング

Boost3 Motal をBoost5 Motalにリファクタリングする時に
いくつかの注意点があります

  • 1.Boost5 MDN リンクを使って、Boost3 の Mdnリンクを置き換える
1
2
3
4
5
6
 <!-- <link rel="stylesheet" href="https://cdn.staticfile.net/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.net/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.net/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> -->

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
  • 2.いくつかの属性名前の変更
1
2
3
4
5
6
7
8
data-toggleを data-bs-toggleに変更する
data-targetをdata-bs-targetに変更する
closeをbtn-closeに変更する
data-targetをdata-bs-targetに変更する
data-dismissをdata-bs-dismissに変更する
btn-defaultをbtn-secondary
form-groupをrowに変更する
control-labelをcolに変更する

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Bootstrap</title>
<!-- <link rel="stylesheet" href="https://cdn.staticfile.net/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.net/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.net/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> -->

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>


</head>
<body>
<div class="container d-flex flex-column justify-content-center align-items-center">
<h2>Book Managerment System</h2>
<button class="btn btn-primary btn-lg" data-bs-toggle="modal" data-bs-target="#myModal">Add</button>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" 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="btn-close" data-bs-dismiss="modal" aria-hidden="true">
&times;
</button>
<h5 class="modal-title text-center w-100 " id="myModalLabel" >Add New Book</h5>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="row mb-4">
<label for="BookName" class="col-sm-2 control-label" id = 'name'>Name</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="BookName">
</div>
</div>
<div class="row mb-4">
<label for="BookAuthor" class="col-sm-2 control-label" id = 'author'>Author</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="BookAuthor" >
</div>
</div>
<div class="row mb-4">
<label for="Bookpublisher" class="col-sm-2 control-label" id = 'publisher'>Publisher</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="Bookpublisher" >
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close
</button>
<button type="button" class="btn btn-primary " id = 'submitBtn'>
Submit
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
</body>
<script src="./js/BookManagerment.js"></script>
</html>