2021年5月10日月曜日

BootStrapを実装サンプルを用いて検証

KingFisherではデザインテンプレートとしてBootstrapを採用したいと思います。(Twitterさんありがとう!)。

Bootstrapは初めて触るので、どんなものか正直手探りですが、まずはサイト(システム)に導入するまでの検証を行いたいと思います。

今回のタスク

  • Bootstrapのライブラリをダウンロード
  • Java Servlet で動くシステムに適用
  • servletを実行するOSはWindowsとする
それでは始めましょう

まずはBootstrapのライブラリをダウンロードします

 https://getbootstrap.jp/へアクセスします

ダウンロードボタンをクリックします

ダウンロードボタンをクリックします

ダウンロードされたzipの中を見るとcssとjsフォルダあありますので、まずbootstrap.css

そしてbootstrap.jsを作成しているservletの開発環境へ持ち込みます

ログイン画面を実装してみます
1つめのポイントは、headタグでbootstrap.cssを読み込むように設定します
<!-- Bootstrap core CSS -->
<head>
<link rel="stylesheet" href="<%= request.getContextPath() %>/contents/css/bootstrap.css"/>
2つめのポイントは、bodyタグの最後でbootstrap.jsを読み込むように設定します
    <script src="<%= request.getContextPath() %>/js/bootstrap.js"></script>
</body>
完成したjspです
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:useBean id="Form0010" scope="request" class="jp.co.ngs.kingfisher.form.Form0010" />
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="NipponGuideSystem,.Co.Ltd.">
<META name="description" content="kingfisher">
<META name="keywords" content="kingfisher,販売管理システム">
<title>Login</title>
<style>

.form-signin-message {
	width: 100%;
}
.form-signin {
	width: 100%;
	max-width: 330px;
	padding: 15px;
	margin: auto;
}


.form-signin .form-floating:focus-within {
	z-index: 2;
}

.form-signin input[type="text"] {
	margin-bottom: -1px;
	border-bottom-right-radius: 0;
	border-bottom-left-radius: 0;
}

.form-signin input[type="password"] {
	margin-bottom: 10px;
	border-top-left-radius: 0;
	border-top-right-radius: 0;
}
</style>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="<%= request.getContextPath() %>/contents/css/bootstrap.css"/>

</head>
<!--  <body class="text-center"> -->
<body class="d-flex flex-column h-100">
	<header class="form-signin-message">
		<div class="container">
			<div class="pgm-message text-danger">
				<ul>
					<c:forEach var="data" items="${Form0010.strMessages}">
						<li><c:out value="${data}" /></li>
					</c:forEach>
				</ul>
			</div>
		</div>
	</header>
	<main class="form-signin">
		<div class="container">
		<form method="post" action="./Ctrl0010">
			<h1 class="h3 mb-3 fw-normal">Login</h1>
			<input type="text" id="inputorgId" class="form-control"
				placeholder="組織ID" required autofocus name="orgId" size="8"
				maxlength="8" value="<c:out value="${Form0010.orgId}"/>">
			<input	type="text" id="inputloginid" class="form-control"
				placeholder="ユーザーID" required name="loginId" size="20"
				maxlength="64" value="<c:out value="${Form0010.loginId}"/>">
			<input type="password" id="inputPassword" class="form-control"
				placeholder="パスワード" required name="loginPassword" size="20"
				maxlength="64" value="<c:out value="${Form0010.loginPassword}"/>">
			<button class="w-100 btn btn-lg btn-primary" type="submit">LOGIN</button>
			<p class="mt-5 mb-3 text-muted">© 2021 NipponGuideSystem</p>
		</form>
		</div>
	</main>

    <script src="<%= request.getContextPath() %>/js/bootstrap.js"></script>
</body>
</html>
実行した結果


bootstrapまだまだVersion5の情報が少ないですが、公式マニュアルが充実していますので
そちらを参考にしながら、開発がすすめられそうです。


0 件のコメント:

コメントを投稿

適格請求書等保存方式(インボイス制度)と消費税の端数処理

消費税の税額計算は 売上税額-仕入れ税額=納税額 2023年10月以降、この納税額の計算の元になる請求書は適格請求書(インボイス)の保存が必要となる。 2019年10月から消費税が10%に引き上げられる際に、日用品等は8%に据え置かれ複数税率を扱う事業者が発生する。 この軽減税率...