前言
这是一个简单的响应式项目,模仿了Alloy Team|腾讯全端部分内容,模拟了可以适应不同类型的设备
项目总览
整体布局
屏幕大于1200px概况:
头部标签hover + 轮播图
屏幕在小于992px概况
头部背景变色 + 固定
屏幕在小于992px概况
屏幕大于768px,小于992px概况
主体部分
屏幕小于768px概况
源码
HTML(index.html)代码
此项目引入的是 Bootstrap框架的CSS、JS、font(图标)代码,需框架代码可在官网自行下载
Bootstrap框架v5中文官网:Bootstrap 入门 · Bootstrap v5 中文文档 v5.3 | Bootstrap 中文网 (bootcss.com)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AlloyTeam|腾讯全端 AlloyTeam 团队</title>
<!-- 层叠性:我们的css 要 层叠 框架的 -->
<link rel="stylesheet" href="./Bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="./Bootstrap/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<!-- 导航开始 -->
<nav class="navbar navbar-expand-lg bg-body-tertiary fixed-top">
<div class="container">
<a class="navbar-brand" href="#"><img src="./assets/images/logo.svg" 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 bi-list"></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 hot" 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>
<!-- 导航结束 -->
<!-- 轮播图 -->
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<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" data-bs-interval="3000"></div>
<div class="carousel-item" data-bs-interval="3000"> </div>
<div class="carousel-item" data-bs-interval="3000"></div>
<div class="carousel-item" data-bs-interval="3000"></div>
</div>
</div>
<!-- 开源项目 -->
<div class="project container">
<!-- 标题 -->
<div class="title">
<span class="txt">
<span>OpenSource</span>
<span>/</span>
开源项目
</span>
<p>种类众多的开源项目,让你爱不释手</p>
</div>
<!-- 内容 -->
<div class="content">
<div class="row">
<div class="col-lg-3 col-md-6"><a href="#">
<img src="./assets/uploads/omi-1.png" alt="">
<h3>OMI</h3>
<p>开放现代的Web组件化框架</p>
</a></div>
<div class="col-lg-3 col-md-6"><a href="#">
<img src="./assets/uploads/alloyimage-2.png" alt="">
<h3>AlloyImage</h3>
<p>HTML5专业级图像处理引擎</p>
</a></div>
<div class="col-lg-3 col-md-6"><a href="#">
<img src="./assets/uploads/alloytouch-3.png" alt="">
<h3>AlloyTouch</h3>
<p>丝般顺滑的触摸运动方案</p>
</a></div>
<div class="col-lg-3 col-md-6"><a href="#">
<img src="./assets/uploads/sodalogo-4.png" alt="">
<h3>Soda</h3>
<p>高性能模版引擎</p>
</a></div>
</div>
</div>
<!-- 更多开源 -->
<div class="more">
<a href="#" class="btn btn-default btn-lg">更多开源 ></a>
</div>
</div>
<script src="./Bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
CSS样式(index.css)代码:
@media (min-width: 1200px) {
.container {
width: 1170px;
}
}
.bg-body-tertiary {
background-color: transparent !important;
}
.bg-body-tertiary .navbar-brand img {
width: 200px;
height: 39px;
}
.bg-body-tertiary .navbar-toggler {
border: 1px solid transparent;
}
.bg-body-tertiary .navbar-toggler:focus {
box-shadow: none;
}
.bg-body-tertiary .bi-list {
font-size: 30px;
color: #fff;
}
@media (max-width: 992px) {
.bg-body-tertiary .navbar-collapse {
position: absolute;
left: 0;
top: 60px;
width: 100%;
background: #26282c;
}
}
.bg-body-tertiary .navbar-collapse {
flex-grow: 0;
}
.bg-body-tertiary .navbar-nav .nav-item a {
text-align: center;
}
.bg-body-tertiary .navbar-nav .nav-link.active {
color: #f2b535;
}
.bg-body-tertiary .navbar-nav .nav-link.hot::before {
content: "";
display: inline-block;
position: relative;
top: 2px;
left: -2px;
width: 13px;
height: 15px;
background: url(../assets/images/hot-32d.png) 50% no-repeat;
background-size: 100% 100%;
}
.bg-body-tertiary .navbar-nav .nav-link.hot {
background-image: -webkit-linear-gradient(left, #cddc39, #ff9800 25%, #cddc39 50%, #ff9800 75%, #cddc39) !important;
-webkit-text-fill-color: transparent !important;
-webkit-background-clip: text !important;
-webkit-background-size: 200% 100% !important;
-webkit-animation: masked-animation 2s infinite linear !important;
}
.bg-body-tertiary .navbar-nav .nav-link {
color: hsla(0, 0%, 100%, 0.65);
}
.bg-body-tertiary .navbar-nav .nav-link:hover {
color: #f2b535;
}
@media (max-width: 992px) {
.bg-body-tertiary {
background-color: #26282c !important;
}
}
@media (max-width: 768px) {
.carousel .carousel-indicators [data-bs-target] {
width: 30px;
}
}
@media (min-width: 768px) {
.carousel .carousel-indicators [data-bs-target] {
width: 50px;
}
}
.carousel .carousel-indicators [data-bs-target] {
margin-right: 5px;
margin-left: 5px;
height: 4px;
}
@media (max-width: 768px) {
.carousel .carousel-item {
height: 250px;
}
}
@media (min-width: 768px) {
.carousel .carousel-item {
height: 400px;
}
}
@media (min-width: 992px) {
.carousel .carousel-item {
height: 500px;
}
}
.carousel .carousel-item {
background-size: cover;
background-position: center;
}
.carousel .carousel-item:nth-child(1) {
background-image: url(../assets/images/banner_1.jpg);
}
.carousel .carousel-item:nth-child(2) {
background-image: url(../assets/images/banner_2.jpg);
}
.carousel .carousel-item:nth-child(3) {
background-image: url(../assets/images/banner_3.jpg);
}
.carousel .carousel-item:nth-child(4) {
background-image: url(../assets/images/banner_4.jpg);
}
.project {
margin-top: 60px;
text-align: center;
}
.project .title .txt {
font-weight: 500;
font-size: 30px;
color: #494d55;
}
.project .title .txt span {
font-family: Segoe UI Light, Microsoft YaHei, Arial, Helvetica, sans-serif;
}
.project .title p {
margin-top: 10px;
margin-bottom: 20px;
font-size: 16px;
color: #919191;
}
.project .row div {
height: 200px;
}
.project .row div a {
display: block;
padding: 20px 10px;
margin-bottom: 10px;
height: 190px;
background-color: aqua;
text-decoration: none;
color: #fff;
border-radius: 4px;
overflow: hidden;
}
.project .row div a img {
height: 60px;
}
.project .row div a h3 {
margin-top: 20px;
margin-bottom: 10px;
font-size: 24px;
}
.project .row div a:hover {
transform: translateY(-6px);
-webkit-transform: translateY(-6px);
-moz-transform: translateY(-6px);
box-shadow: 0 26px 40px -24px rgba(0, 36, 100, 0.5);
-webkit-box-shadow: 0 26px 40px -24px rgba(0, 36, 100, 0.5);
-moz-box-shadow: 0 26px 40px -24px rgba(0, 36, 100, 0.5);
}
.project .row div:nth-child(1) a {
background-color: #70c3ff;
}
.project .row div:nth-child(2) a {
background-color: #fd6a7f;
}
.project .row div:nth-child(3) a {
background-color: #7f8ea0;
}
.project .row div:nth-child(4) a {
background-color: #89d04f;
}
.project .more {
display: block;
margin: 0 auto;
text-align: center;
padding: 10px;
border: 1px solid #fff;
box-shadow: 6px 6px 0 #fff;
width: 200px;
cursor: pointer;
}
.project .more a {
background-color: #e1e1e1;
color: #616161;
font-weight: 400;
font-size: 14px;
}