Bootstrap(书籍搜索&表格实现购物车)

前言:亲爱的读者们,今天给一些代码小白分享一下两个案例。

话不多说,直接上代码。

导入依赖:

        <!-- 引入Bootstrap css类库 -->
        <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
        <!-- 引入jQuery类库 -->
        <script src="js/jquery-3.6.0.js" type="text/javascript" charset="utf-8"></script>
        <!-- 引入Bootstrap类库 -->
        <script src="js/bootstrap.js" type="text/javascript" charset="utf-8"></script>

 案例01:表格实现购物车

 

<!--购物车-->
				<div class="col-md-9">
					<!-- 表格 table-striped-->
					<table class="table table-striped">
						<thead>
							<tr class="bg-primary text-white">
								<th scope="col">
									<input type="checkbox">全选
								</th>
								<th scope="col">商品名称</th>
								<th scope="col">图片</th>
								<th scope="col">单价</th>
								<th scope="col">数量</th>
								<th scope="col">总价格</th>
								<th scope="col">操作</th>
							</tr>
						</thead>
						<tbody>
							<!-- 名称导航条背景 -->
							<tr class="bg-primary text-white">
							<tr>
								<th scope="row"><input type="checkbox" name="" id="" value="" /></th>
								<td>章游那悲惨的爱情故事</td>
								<td><img src="img/2.png"></td>
								<td>¥1.00</td>
								<td>
									<!-- 数量  输入框组 -->
									<div class="input-group mb-3" style="width: 120px;">
										<div class="input-group-append">
											<button class="btn btn-outline-secondary" type="button" id="button-addon2">-</button>
										</div>
										<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username"
										 aria-describedby="button-addon2">
										<div class="input-group-append">
											<button class="btn btn-outline-secondary" type="button" id="button-addon2">+</button>
										</div>
									</div>
								</td>
								<td>¥1.00</td>
								<td><button type="button" class="btn btn-danger">移除</button></td>
							</tr>
							</tr>
							<tr>
								<th scope="row"><input type="checkbox" name="" id="" value="" /></th>
								<td>章游那悲惨的爱情故事</td>
								<td><img src="img/2.png"></td>
								<td>¥1.00</td>
								<td>
									<!-- 数量  输入框组 -->
									<div class="input-group mb-3" style="width: 120px;">
										<div class="input-group-append">
											<button class="btn btn-outline-secondary" type="button" id="button-addon2">-</button>
										</div>
										<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username"
										 aria-describedby="button-addon2">
										<div class="input-group-append">
											<button class="btn btn-outline-secondary" type="button" id="button-addon2">+</button>
										</div>
									</div>
								</td>
								<td>¥1.00</td>
								<td><button type="button" class="btn btn-danger">移除</button></td>
							</tr>
							<tr>
								<th scope="row"><input type="checkbox" name="" id="" value="" /></th>
								<td>章游那悲惨的爱情故事</td>
								<td><img src="img/2.png"></td>
								<td>¥1.00</td>
								<td>
									<!-- 数量  输入框组 -->
									<div class="input-group mb-3" style="width: 120px;">
										<div class="input-group-append">
											<button class="btn btn-outline-secondary" type="button" id="button-addon2">-</button>
										</div>
										<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username"
										 aria-describedby="button-addon2">
										<div class="input-group-append">
											<button class="btn btn-outline-secondary" type="button" id="button-addon2">+</button>
										</div>
									</div>
								</td>
								<td>¥1.00</td>
								<td><button type="button" class="btn btn-danger">移除</button></td>
							</tr>
						</tbody>
					</table>

按钮样式:

 

<p id="btn" class="text-center">
				<button type="button" class="btn-warning">清空购物车</button>
				<button type="button" class="btn-success">返回购物车</button>
				<button type="button" class="btn-danger">结算</button>
</p>

 02案例:媒体对象实现搜索书籍输入框

 

<!-- 搜索输入框-->
<div class="input-group mb-3">
		<input type="text" class="form-control" 
   placeholder="搜索书籍" aria-label="Recipient's username"
									 aria-describedby="basic-addon2">
<div class="input-group-append">
	<span class="btn btn-primary" id="basic-addon2">
搜索</span>

	</div>
</div>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值