使用HTML+CSS+Bootstrap4.6,要求代码中有注释,仿做酷我音乐https://www.kugou.com/首页的头部部分,以上需要图片的部分在https://picsum.photos网站上根据尺寸随机选择
时间: 2023-12-11 09:04:19 浏览: 101
html+css设计一个音乐网站
好的,以下是实现该需求的HTML、CSS和Bootstrap代码,已经添加了注释。图片部分使用了picsum.photos网站来随机选择尺寸:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入Bootstrap样式文件 -->
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
<title>仿做酷我音乐首页头部</title>
<style>
/* 自定义样式 */
.navbar-brand img {
height: 30px;
}
.navbar-nav .nav-item .nav-link {
color: #fff;
}
.navbar-nav .nav-item:hover .nav-link {
color: #f60;
}
.download-btn {
background-color: #f60;
color: #fff;
border-radius: 20px;
font-size: 14px;
padding: 8px 20px;
margin-left: 20px;
}
.download-btn:hover {
background-color: #f90;
}
/* 背景图样式 */
.bg-image {
background-image: url('https://picsum.photos/1920/300');
background-size: cover;
background-position: center center;
height: 300px;
}
</style>
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<!-- 导航栏品牌 -->
<a class="navbar-brand" href="#">
<img src="https://picsum.photos/30" alt="酷我音乐">
</a>
<!-- 导航栏菜单 -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">首页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">分类</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">排行榜</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">歌单</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">MV</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">歌手</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">客户端</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">VIP</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">演出</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">商城</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">K歌社</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">数字专辑</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">我的</a>
</li>
</ul>
<!-- 下载按钮 -->
<a href="#" class="download-btn">下载APP</a>
</div>
</div>
</nav>
<!-- 头部背景图 -->
<div class="bg-image"></div>
<!-- 引入jQuery和Bootstrap的JavaScript库 -->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
</body>
</html>
```
注意,该代码需要在支持Bootstrap 4.6的环境下运行,否则可能会出现样式错乱或无法正常使用的情况。同时,为了方便您的使用,我在代码中添加了注释以便您理解每个部分的作用。
阅读全文