在前端开发中,CSS是重要的一部分。它能够让网站变得更加美观、优化用户体验,同时还能让我们更加高效地开发。下面我们来看看如何使用CSS来写QQ音乐界面。/ 统一样式 / { margin: 0; p...
在前端开发中,CSS是重要的一部分。它能够让网站变得更加美观、优化用户体验,同时还能让我们更加高效地开发。下面我们来看看如何使用CSS来写QQ音乐界面。
/* 统一样式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* 头部 */
.header {
height: 80px;
background-color: #ddd;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
}
/* Logo */
.header .logo {
font-size: 24px;
font-weight: bold;
}
/* 搜索框 */
.header .search {
width: 400px;
height: 32px;
border-radius: 16px;
background-color: #fff;
display: flex;
align-items: center;
padding: 0 10px;
}
.header .search input {
flex: 1;
border: none;
outline: none;
}
/* 搜索按钮 */
.header .search-btn {
width: 60px;
height: 32px;
background-color: #3b3f4b;
color: #fff;
border: none;
border-radius: 16px;
margin-left: 10px;
font-size: 16px;
cursor: pointer;
}
/* 导航栏 */
.nav {
height: 60px;
background-color: #1c1d21;
display: flex;
justify-content: center;
align-items: center;
}
.nav ul {
display: flex;
}
.nav li {
list-style: none;
margin-right: 50px;
}
.nav a {
color: #fff;
font-size: 16px;
text-decoration: none;
}
.nav a:hover {
color: #dcdcdc;
}
/* 歌曲列表 */
.song-list {
margin: 20px;
}
.song-list table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
.song-list th {
font-weight: bold;
text-align: left;
border-bottom: 1px solid #ddd;
padding: 10px;
}
.song-list td {
padding: 10px;
border-bottom: 1px solid #ddd;
}
.song-list td span {
color: #999;
}
.song-list td .play-btn {
width: 30px;
height: 30px;
background-color: #3b3f4b;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.song-list td .play-btn svg {
width: 20px;
height: 20px;
fill: #fff;
}
/* 底部 */
.footer {
height: 40px;
line-height: 40px;
text-align: center;
background-color: #f2f2f2;
} 以上就是使用CSS来写QQ音乐界面的代码。我们可以发现,CSS让界面变得更加美观,也更加易于维护。只需要对样式进行维护和修改,就能够改变整个界面的外观。希望这篇文章能够帮助大家更好地理解CSS在前端开发中的应用。