bootstr4ap新闻首页样式
时间: 2023-10-02 15:04:57 浏览: 120
Bootstrap是一个流行的前端框架,可以让开发者快速构建现代化的网站和应用程序。下面是一个基于Bootstrap的新闻首页样式的示例:
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap News</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+JQLhRzKtpBSvJpRL+nKkNk9jUstkkL" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="navbar-brand" href="#">Bootstrap News</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</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">World</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Politics</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Business</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Technology</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Science</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Sports</a>
</li>
</ul>
</div>
</nav>
<div class="container my-4">
<div class="row">
<div class="col-md-8">
<h1 class="mb-4">Latest News</h1>
<div class="card mb-3">
<img src="https://via.placeholder.com/600x400.png?text=Image+1" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Lorem ipsum dolor sit amet</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, libero quis sodales eleifend, odio nibh feugiat nisi, vitae pharetra velit diam a mauris.</p>
<p class="card-text"><small class="text-muted">2 mins ago</small></p>
</div>
</div>
<div class="card mb-3">
<img src="https://via.placeholder.com/600x400.png?text=Image+2" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Suspendisse potenti</h5>
<p class="card-text">Suspendisse potenti. Proin cursus, quam eu sollicitudin semper, velit lorem tristique neque, vel porta ligula magna vel purus.</p>
<p class="card-text"><small class="text-muted">1 hour ago</small></p>
</div>
</div>
<div class="card mb-3">
<img src="https://via.placeholder.com/600x400.png?text=Image+3" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Nam efficitur mi sed mi fringilla</h5>
<p class="card-text">Nam efficitur mi sed mi fringilla aliquam. Nullam vel vestibulum mauris, nec laoreet justo. Duis sodales ante non tincidunt scelerisque.</p>
<p class="card-text"><small class="text-muted">3 hours ago</small></p>
</div>
</div>
</div>
<div class="col-md-4">
<h2 class="mb-4">Popular News</h2>
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">
<img src="https://via.placeholder.com/60x60.png?text=Image+1" alt="" class="mr-3">
Lorem ipsum dolor sit amet
</a>
<a href="#" class="list-group-item list-group-item-action">
<img src="https://via.placeholder.com/60x60.png?text=Image+2" alt="" class="mr-3">
Suspendisse potenti
</a>
<a href="#" class="list-group-item list-group-item-action">
<img src="https://via.placeholder.com/60x60.png?text=Image+3" alt="" class="mr-3">
Nam efficitur mi sed mi fringilla
</a>
<a href="#" class="list-group-item list-group-item-action">
<img src="https://via.placeholder.com/60x60.png?text=Image+4" alt="" class="mr-3">
Fusce auctor, odio vel gravida
</a>
<a href="#" class="list-group-item list-group-item-action">
<img src="https://via.placeholder.com/60x60.png?text=Image+5" alt="" class="mr-3">
Proin cursus, quam eu sollicitudin
</a>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+JQLhRzKtpBSvJpRL+nKkNk9jUstkkL" crossorigin="anonymous"></script>
</body>
</html>
```
这个样式包括一个顶部导航栏,最新新闻和热门新闻列表。它是使用Bootstrap的网格系统和卡片组件来排列内容的。同时,它也包括了Bootstrap的CSS和JavaScript文件。
阅读全文