3、综合案例-AlloyTeam
移动全端
准备工作
< title> 腾讯全端</ title>
< link rel = " shortcut icon" href = " favicon.ico" type = " image/x-icon" >
< link rel = " stylesheet" href = " ./Bootstrap/css/bootstrap.min.css" >
< link rel = " stylesheet" href = " ./Bootstrap/font/bootstrap-icons.css" >
< link rel = " stylesheet" href = " ./css/index.css" >
< script src = " ./Bootstrap/js/bootstrap.min.js" > </ script>
// out: ../css/
头部导航
< nav class = " navbar navbar-expand-lg bg-body-tertiary fixed-top" >
< div class = " container" >
< a class = " navbar-brand" href = " #" > < img src = " ./assets/images/logo.png" alt = " " > </ a>
< button class = " navbar-toggler" type = " button" data-bs-toggle = " collapse" data-bs-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" >
< a class = " nav-link active" aria-current = " page" href = " #" > 首页</ a>
</ li>
< li class = " nav-item" >
< a class = " nav-link" href = " #" > 博客</ a>
</ li>
< li class = " nav-item" >
< a class = " nav-link" href = " #" > Github</ a>
</ li>
< li class = " nav-item" >
< a class = " nav-link" href = " #" > TWeb Conf</ a>
</ li>
< li class = " nav-item" >
< a class = " nav-link" href = " #" > SuperStar</ a>
</ li>
< li class = " nav-item" >
< a class = " nav-link" href = " #" > Web前端导航</ a>
</ li>
< li class = " nav-item" >
< a class = " nav-link" href = " #" > 关于</ a>
</ li>
</ ul>
</ div>
</ div>
</ nav>
// 导航
.bg-body-tertiary {
background-color: transparent !important;
.navbar-collapse {
flex-grow: 0;
}
}
轮播图图片
< div id = " carouselExampleIndicators" class = " carousel slide" >
< div class = " carousel-indicators" >
< button type = " button" data-bs-target = " #carouselExampleIndicators" data-bs-slide-to = " 0" class = " active" aria-current = " true" aria-label = " Slide 1" > </ button>
< button type = " button" data-bs-target = " #carouselExampleIndicators" data-bs-slide-to = " 1" aria-label = " Slide 2" > </ button>
< button type = " button" data-bs-target = " #carouselExampleIndicators" data-bs-slide-to = " 2" aria-label = " Slide 3" > </ button>
< button type = " button" data-bs-target = " #carouselExampleIndicators" data-bs-slide-to = " 3" aria-label = " Slide 4" > </ button>
</ div>
< div class = " carousel-inner" >
< div class = " carousel-item active" >
</ div>
< div class = " carousel-item" >
</ div>
< div class = " carousel-item" >
</ div>
< div class = " carousel-item" >
</ div>
</ div>
< button class = " carousel-control-prev" type = " button" data-bs-target = " #carouselExampleIndicators" data-bs-slide = " prev" >
< span class = " carousel-control-prev-icon" aria-hidden = " true" > </ span>
< span class = " visually-hidden" > Previous</ span>
</ button>
< button class = " carousel-control-next" type = " button" data-bs-target = " #carouselExampleIndicators" data-bs-slide = " next" >
< span class = " carousel-control-next-icon" aria-hidden = " true" > </ span>
< span class = " visually-hidden" > Next</ span>
</ button>
</ div>
.carousel {
.carousel-item {
height: 500px;
background-size: cover;
background-position: center 0;
}
.carousel-item:nth-child(1) {
background-image: url(../assets/uploads/banner_1.jpg);
}
.carousel-item:nth-child(2) {
background-image: url(../assets/uploads/banner_2.jpg);
}
.carousel-item:nth-child(3) {
background-image: url(../assets/uploads/banner_3.jpg);
}
.carousel-item:nth-child(4) {
background-image: url(../assets/uploads/banner_4.jpg);
}
}
轮播图响应式
// 轮播图: 小于768图片高度250 max;大于等于768图片高度400 min;大于等于992图片高度500
.carousel {
// 响应式 → 媒体查询
@media (max-width: 768px) {
.carousel-item {
height: 250px;
}
}
@media (min-width: 768px) {
.carousel-item {
height: 400px;
}
}
@media (min-width: 992px) {
.carousel-item {
height: 500px;
}
}
.carousel-item {
// height: 500px;
background-size: cover;
background-position: center 0;
}
}
开源项目响应式
< div class = " project container" >
< div class = " title" >
< h2> OpenSource / 开源项目</ h2>
< p> 种类众多的开源项目,让你爱不释手</ p>
</ div>
< div class = " content" >
< div class = " row" >
< div class = " col-lg-3 col-md-6" > 1</ div>
< div class = " col-lg-3 col-md-6" > 2</ div>
< div class = " col-lg-3 col-md-6" > 3</ div>
< div class = " col-lg-3 col-md-6" > 4</ div>
</ div>
</ div>
</ div>
// 开源项目
// 视口宽度大于992;一行排4个盒子 col-lg-3
// 视口宽度大于768;一行排2个盒子 col-md-6
.project {
margin-top: 60px;
text-align: center;
}
开源项目内容布局
< div class = " project container" >
< div class = " title" >
< h2> OpenSource / 开源项目</ h2>
< p> 种类众多的开源项目,让你爱不释手</ p>
</ div>
< div class = " content" >
< div class = " row" >
< div class = " col-lg-3 col-md-6" > < a href = " #" > 1</ a> </ div>
< div class = " col-lg-3 col-md-6" > < a href = " #" > 1</ a> </ div>
< div class = " col-lg-3 col-md-6" > < a href = " #" > 1</ a> </ div>
< div class = " col-lg-3 col-md-6" > < a href = " #" > 1</ a> </ div>
</ div>
</ div>
</ div>
.project {
margin-top: 60px;
text-align: center;
.row {
div {
margin-bottom: 10px;
height: 200px;
// background-color: pink;
a {
// 块级的宽度和父级一样大
display: block;
height: 200px;
background-color: green;
border-radius: 4px;
}
&:nth-child(1) a {
background-color: #70c3ff;
}
&:nth-child(2) a {
background-color: #fd6a7f;
}
&:nth-child(3) a {
background-color: #7f8ea0;
}
&:nth-child(4) a {
background-color: #89d04f;
}
}
}
}