Bootstrap完成前端简单界面

本文档详细介绍了网上书城的界面设计与实现过程,包括登录、注册、主页、搜索和购物车等功能的HTML、CSS和JS代码,以及Bootstrap框架的使用。通过具体代码示例,展示了各页面的布局、样式和交互效果。
摘要由CSDN通过智能技术生成

所需js,css

个人css:
*{
	margin: 0;
	padding: 0;
}
/* 搜索栏 start */
.search-parent{
	position: relative;
	height: 100px;
	}
.search{
	position: absolute;
	background-color: #D6CCBB;
	width: 1140px;
	height: 90px;	
}
.search-parent input{
	position: absolute;
	top: 30px;
	left: 400px;
	z-index: 2;
}
.search-parent button{
	position: absolute;
	top: 27px;
	left: 575px;
	z-index: 2;
}
/* 搜索栏 end */

/* 主内容区 start*/

.bg-color1{
	background-color: #710503 ;
}
.bg-color2{
	background-color: #F7E4E4 ;
}
.bg-opacity{
	opacity: 0.3;
}
.c-category li{
	cursor: pointer;
	text-align: center;
}

.guangao>img{
	width: 725px;	
}
.l-content{
	padding-right: 0;
}
.r-content{
	padding: 0;
}

.tip{
	position: relative;
	height: 40px;
	width: 725px;
	background-color: #F7F6F6;
}
.tip>img{
	position: absolute;
}
.tip>h5{
	position: absolute;
	left: 20px;
}

.book img{
	width: 80px;
	height: 110px;
}
.book p{
	margin-bottom: 0;
}
.book>div{
	padding: 0;
}

.shop-table-tab{
	margin: 0 110px;
}
/* 主内容区 end*/

其余js,与css可用Bootstrap的

界面及效果

登录

<html>
<head>
    <title>网上书城登录</title>
    <link href="../bootstrap-4.5.0-dist/css/bootstrap.css" rel="stylesheet">
    <link href="../css/fg.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
    <script src="bootstrap.js"></script>

</head>
<body class="text-center">
<form class="form-signin" action="${pageContext.request.contextPath}/user.action?methodName=login" method="post">
    <h1 class="h3 mb-3 font-weight-normal">用户登录</h1>
    <label for="name" class="sr-only">账号</label>
    <input type="text" id="name" name="name" class="form-control" placeholder="请输入账号" required autofocus>
    <label for="pwd" class="sr-only">密码</label>
    <input type="password" id="pwd" name="pwd" class="form-control" placeholder="请输入密码" required>
    <div class="checkbox mb-3">
        <label>
            <input type="checkbox" value="remember-me"> Remember me
        </label>
    </div>
    <button class="btn btn-lg btn-primary btn-block" type="submit" id="login">登录</button>
    <p class="mt-5 mb-3 text-muted">& 2017-2020</p>
</form>


</body>
</html>

在这里插入图片描述

注册

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>注册界面</title>
		<link rel="stylesheet" type="text/css" href="../css/bootstrap.css" />
		<style>
			.form-signin{
				/* position: absolute;  绝对定位*/
				/* position: relative; 绝对定位*/
				position: relative;
				width: 400px;
				top: 100px;
				left: 50%;
				margin-left: -200px;
			}
		</style>
	</head>
	<body>
		<form class="form-signin" action="" method="post">
			<div class="text-center mb-4">
				<img class="mb-4" src="/docs/assets/brand/bootstrap-solid.svg" alt="" width="72" height="72">
				<h1 class="h3 mb-3 font-weight-normal">用户注册</h1>				
			</div>

			<div class="form-label-group">
				<input type="text" id="name" name="name" class="form-control" placeholder="请输入用户名..." required autofocus>
			</div>

			<div class="form-label-group">
				<input type="password" id="pwd" name="pwd" class="form-control" placeholder="请输入密码..." required>
			</div>

			<div class="checkbox mb-3">
				<label>
					<input type="checkbox" value="remember-me"> Remember me
				</label>
			</div>
			<button class="btn btn-lg btn-primary btn-block" type="submit">注册</button>
			<p class="mt-5 mb-3 text-muted text-center">&copy; 2017-2020</p>
		</form>

		<script src="js/bootstrap.min.js"></script>
	</body>
</html>

在这里插入图片描述

主页

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>首页</title>
		<link rel="stylesheet" type="text/css" href="bootstrap-4.5.0-dist/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="css/fg.css" />
	</head>
	<body>

		<div class="container">
			<!-- 横幅 -->
			<div class="row">
				<div class="col-sm-4">
					您好,欢迎来到网上书城!
				</div>
				<div class="col-sm-4 col-sm-offset-4" style="margin-left: 350px;">
					<a href="#">登录</a> | <a href="#">注册</a> | <b>我的购物车</b> | <i>网站首页</i>
				</div>
			</div>
			<!-- 搜索栏 -->
			<div class="row">
				<div class="col-sm-12 search-parent">
					<!-- 本来这里应该放一张背景图的 -->
					<div class="search"></div>
					<input type="text" id="book_name" name="name" value="" />
					<button type="button" class="btn btn-primary">搜索</button>
				</div>
			</div>
			<!-- 主内容区 -->
			<div class="row content">
				<div class="col-sm-3 l-content">
					<ul class="list-group c-category ">
						<li class="list-group-item" style="color: white;">书籍分类</li>
						<li class="list-group-item">现代言情</li>
						<li class="list-group-item">古代言情</li>
						<li class="list-group-item">幻想仙侠</li>
						<li class="list-group-item">玄幻</li>
						<li class="list-group-item">都市</li>
						<li class="list-group-item">奇幻</li>
						<li class="list-group-item">军事</li>
						<li class="list-group-item">科幻</li>
						<li class="list-group-item">武侠</li>
						<li class="list-group-item">青春</li>
						<li class="list-group-item">竞技</li>
						<li class="list-group-item">历史</li>
						<li class="list-group-item">游戏</li>
						<li class="list-group-item">其他</li>
					</ul>
				</div>
				<div class="col-sm-9 r-content">
					<!-- 广告 -->
						<img src="img/banner.png" class="img-thumbnail" style="width: 1000px;height: 300px;" alt="...">

					<!-- 新书上架 -->
					<div class="news container">
						<div class="tip row">
							<img src="img/title_bj.png" />
							<h5 style="color: white;">新书上架</h5>
						</div>
						<div class="row book">
							<div class="col-sm-2">
								<img src="img/3.png" />
								<p>狂人日记</p>
								<b style="color: red;">12</b>
							</div>
							<div class="col-sm-2">
								<img src="img/3.png" />
								<p>狂人日记</p>
								<b style="color: red;">12</b>
							</div>
							<div class="col-sm-2">
								<img src="img/3.png" />
								<p>狂人日记</p>
								<b style="color: red;">12</b>
							</div>
							<div class="col-sm-2">
								<img src="img/3.png" />
								<p>狂人日记</p>
								<b style="color: red;">12</b>
							</div>
							<div class="col-sm-3">
								<img src="img/3.png" />
								<p>狂人日记</p>
								<b style="color: red;">12</b>
							</div>
							
						</div>
					</div>

					<!-- 热销 -->
					<div class="hots container">
						<div class="tip row">
							<img src="img/title_bj.png" />
							<h5 style="color: white;">热销图书</h5>
						</div>
						<div class="row book">
							<div class="col-sm-2">
								<img src="img/1.png" />
								<p>冷间谍</p>
								<b style="color: red;">12</b>
							</div>
							<div class="col-sm-2">
								<img src="img/1.png" />
								<p>冷间谍</p>
								<b style="color: red;">12</b>
							</div>
							<div class="col-sm-2">
								<img src="img/1.png" />
								<p>冷间谍</p>
								<b style="color: red;">12</b>
							</div>
							<div class="col-sm-2">
								<img src="img/1.png" />
								<p>冷间谍</p>
								<b style="color: red;">12</b>
							</div>
							<div class="col-sm-2">
								<img src="img/1.png" />
								<p>冷间谍</p>
								<b style="color: red;">12</b>
							</div>
							
						</div>
					</div>
				</div>
			</div>
			<!-- 底部版权 -->
			<div class="row">
				<div class="col-sm-12 text-center">
					版权所有
				</div>
			</div>
		</div>
		<script src="js/jquery-3.3.1.js"></script>
		<script src="bootstrap-4.5.0-dist/js/bootstrap.min.js"></script>
		<script type="text/javascript">
			$(function() {
				$(".c-category li").eq(0).addClass('bg-color1');
				$(".c-category li:gt(0)").addClass('bg-color2');
				$(".c-category li:gt(0)").hover(function() {
					$(this).addClass('bg-opacity');
				}, function() {
					$(this).removeClass('bg-opacity');
				});
			})
		</script>
	</body>
</html>

在这里插入图片描述

搜索

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>搜索页</title>
		<link rel="stylesheet" type="text/css" href="../css/bootstrap.css" />
		<link rel="stylesheet" type="text/css" href="../css/fg.css" />
	</head>
	<body>

		<div class="container">
			<!-- 横幅 -->
			<div class="row">
				<div class="col-sm-4">
					您好,欢迎来到网上书城!
				</div>
				<div class="col-sm-4 col-sm-offset-4">
					<a href="#">登录</a> | <a href="#">注册</a> | <b>我的购物车</b> | <i>网站首页</i>
				</div>
			</div>
			<!-- 搜索栏 -->
			<div class="row">
				<div class="col-sm-12 search-parent">
					<!-- 本来这里应该放一张背景图的 -->
					<div class="search"></div>
					<input type="text" id="book_name" name="name" value="" />
					<button type="button" class="btn btn-primary">搜索</button>
				</div>
			</div>
			<!-- 主内容区 -->
			<div class="row content">
				<div class="col-sm-3 l-content">
					<ul class="list-group c-category ">
						<li class="list-group-item" style="color: white;">书籍分类</li>
						<li class="list-group-item">现代言情</li>
						<li class="list-group-item">古代言情</li>
						<li class="list-group-item">幻想仙侠</li>
						<li class="list-group-item">玄幻</li>
						<li class="list-group-item">都市</li>
						<li class="list-group-item">奇幻</li>
						<li class="list-group-item">军事</li>
						<li class="list-group-item">科幻</li>
						<li class="list-group-item">武侠</li>
						<li class="list-group-item">青春</li>
						<li class="list-group-item">竞技</li>
						<li class="list-group-item">历史</li>
						<li class="list-group-item">游戏</li>
						<li class="list-group-item">其他</li>
					</ul>
				</div>
				<div class="col-sm-9">
					<div class="media">
						<img src="img/2.png" class="align-self-center mr-3" alt="...">
						<div class="media-body">
							<p>第一商会</p>
							<p>作者:</p>
							<p>价格:¥24</p>
							<p>出版社:丛恒文学</p>
							<p>简介:三天更一章</p>
							<p>
								<button class="btn btn-danger" style="width: 150px;">加入购物车</button>
								<button class="btn btn-danger" style="width: 150px;">去结算</button>
							</p>
						</div> 						
					</div>
					<div class="media">
						<img src="img/2.png" class="align-self-center mr-3" alt="...">
						<div class="media-body">
							<p>第一商会</p>
							<p>作者:</p>
							<p>价格:¥24</p>
							<p>出版社:丛恒文学</p>
							<p>简介:三天更一章</p>
							<p>
								<button class="btn btn-danger" style="width: 150px;">加入购物车</button>
								<button class="btn btn-danger" style="width: 150px;">去结算</button>
							</p>
						</div> 						
					</div>
				</div>
			</div>
			<!-- 底部版权 -->
			<div class="row">
				<div class="col-sm-12 text-center">
					版权所有
				</div>
			</div>
		</div>
		<script src="jquery-3.3.1.js"></script>
		<script src="bootstrap.js"></script>
		<script type="text/javascript">
			$(function() {
				$(".c-category li").eq(0).addClass('bg-color1');
				$(".c-category li:gt(0)").addClass('bg-color2');
				$(".c-category li:gt(0)").hover(function() {
					$(this).addClass('bg-opacity');
				}, function() {
					$(this).removeClass('bg-opacity');
				});
			})
		</script>
	</body>
</html>

在这里插入图片描述

购物车

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>购物车</title>
		<link rel="stylesheet" type="text/css" href="../bootstrap-4.5.0-dist/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/fg.css" />
	</head>
	<body>

		<div class="container">
			<!-- 横幅 -->
			<div class="row">
				<div class="col-sm-4">
					您好,欢迎来到网上书城!
				</div>
				<div class="col-sm-4 col-sm-offset-4">
					<a href="#">登录</a> | <a href="#">注册</a> | <b>我的购物车</b> | <i>网站首页</i>
				</div>
			</div>
			<!-- 搜索栏 -->
			<div class="row">
				<div class="col-sm-12 search-parent">
					<!-- 本来这里应该放一张背景图的 -->
					<div class="search"></div>
					<input type="text" id="book_name" name="name" value="" />
					<button type="button" class="btn btn-primary">搜索</button>
				</div>
			</div>
			<!-- 主内容区 -->
			<div class="row content">
				<div class="col-sm-3 l-content">
					<ul class="list-group c-category ">
						<li class="list-group-item" style="color: white;">书籍分类</li>
						<li class="list-group-item">现代言情</li>
						<li class="list-group-item">古代言情</li>
						<li class="list-group-item">幻想仙侠</li>
						<li class="list-group-item">玄幻</li>
						<li class="list-group-item">都市</li>
						<li class="list-group-item">奇幻</li>
						<li class="list-group-item">军事</li>
						<li class="list-group-item">科幻</li>
						<li class="list-group-item">武侠</li>
						<li class="list-group-item">青春</li>
						<li class="list-group-item">竞技</li>
						<li class="list-group-item">历史</li>
						<li class="list-group-item">游戏</li>
						<li class="list-group-item">其他</li>
					</ul>
				</div>
				<div class="col-sm-9">
					<table class="table">
						<thead class="thead-dark">
							<tr style="background-color: papayawhip;">
								<th scope="col">书名</th>
								<th scope="col">单价</th>
								<th scope="col">数量</th>
								<th scope="col">小计</th>
								<th scope="col">操作</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td>Mark</td>
								<td>Otto</td>
								<td>@mdo</td>
								<td>Mark</td>
								<td>
									<a href="#">删除</a>&nbsp;&nbsp;
									<a href="#">更新</a>
								</td>
							</tr>
							<tr>
								<td>Mark</td>
								<td>Otto</td>
								<td>@mdo</td>
								<td>Mark</td>
								<td>
									<a href="#">删除</a>&nbsp;&nbsp;
									<a href="#">更新</a>
								</td>
							</tr>
							<tr>
								<td colspan="5" >
									<div class="btn btn-danger" style="width: 180px;">清空购物车</div>
									<div class="btn btn-danger shop-table-tab" style="width: 180px;">继续购物</div>
									<div class="btn btn-danger" style="width: 180px;">去结算</div>
								</td>  
							</tr>
						</tbody>
					</table>
				</div>
			</div>
			<!-- 底部版权 -->
			<div class="row">
				<div class="col-sm-12 text-center">
					Copyright 2020 教育,版权所有
				</div>
			</div>
		</div>
		<script src="jquery-3.3.1.js"></script>
		<script src="../bootstrap-4.5.0-dist/js/bootstrap.min.js"></script>
		<script type="text/javascript">
			$(function() {
				$(".c-category li").eq(0).addClass('bg-color1');
				$(".c-category li:gt(0)").addClass('bg-color2');
				$(".c-category li:gt(0)").hover(function() {
					$(this).addClass('bg-opacity');
				}, function() {
					$(this).removeClass('bg-opacity');
				});
			})
		</script>
	</body>
</html>

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值