前端开发框架bootstrap实验报告含代码
时间: 2023-08-03 12:09:39 浏览: 253
实验名称:使用Bootstrap开发响应式网站
实验目的:掌握Bootstrap框架的基本使用方法,能够使用Bootstrap开发响应式网站。
实验步骤:
1. 下载Bootstrap框架文件,包括CSS文件和JS文件。
2. 创建HTML文件,引入Bootstrap的CSS和JS文件。
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Bootstrap实验</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery-3.2.1.slim.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
</body>
</html>
```
3. 使用Bootstrap的网格系统布局页面,将页面分成12列,根据需要占用不同的列数。
```html
<div class="container">
<div class="row">
<div class="col-md-4">左侧内容</div>
<div class="col-md-8">右侧内容</div>
</div>
</div>
```
4. 使用Bootstrap的组件,如导航栏、按钮、表格、表单等。
```html
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
<button type="button" class="btn btn-primary">Primary</button>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<td>2</td>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<td>3</td>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me out</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
```
5. 使用Bootstrap的样式,如颜色、字体、边框等。
```html
<h1 class="text-center text-primary">Bootstrap实验</h1>
<div class="card">
<div class="card-header">
Featured
</div>
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
<div class="alert alert-warning" role="alert">
A simple warning alert—check it out!
</div>
<div class="jumbotron">
<h1 class="display-4">Hello, world!</h1>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</div>
```
实验结果:完成了一个响应式网站,具有良好的视觉效果和交互体验。
实验结论:Bootstrap是一个非常实用的前端开发框架,能够快速开发响应式网站,提高开发效率,减少开发难度。通过本次实验,我掌握了Bootstrap的基本使用方法,能够使用Bootstrap开发响应式网站,对于我以后的前端开发工作将会有很大的帮助。
阅读全文