手机端网站模板 - 响应式设计,包含导航、幻灯片、图片列表、服务项目、新闻等
<!DOCTYPE html>
<html>
<head>
<title>手机端网站模板</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
/*导航条样式*/
.navbar {
background-color: #333;
overflow: hidden;
}
<pre><code> .navbar a {
float: left;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.navbar a:hover {
background-color: #ddd;
color: black;
}
/*幻灯片样式*/
.slideshow-container {
max-width: 100%;
position: relative;
margin: auto;
}
.slideshow-container img {
width: 100%;
height: auto;
}
.prev, .next {
position: absolute;
top: 50%;
transform: translateY(-50%);
color: #f2f2f2;
font-size: 18px;
font-weight: bold;
padding: 12px 16px;
border-radius: 0 3px 3px 0;
cursor: pointer;
}
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
.prev:hover, .next:hover {
background-color: rgba(0, 0, 0, 0.8);
}
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/*图片列表样式*/
.img-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
margin: 20px 0;
}
.img-list a {
display: flex;
flex-direction: column;
align-items: center;
margin: 10px;
text-align: center;
text-decoration: none;
color: #000;
}
.img-list img {
width: 100%;
height: auto;
margin-bottom: 5px;
}
.img-list h3 {
background-color: #000;
color: #fff;
padding: 5px;
font-size: 14px;
margin: 0;
width: 100%;
text-align: center;
}
/*服务项目样式*/
.services {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
margin: 20px 0;
}
.services a {
display: flex;
flex-direction: column;
align-items: center;
margin: 10px;
text-align: center;
text-decoration: none;
color: #000;
width: 33.33%;
}
.services img {
width: 50px;
height: 50px;
margin-bottom: 5px;
}
.services h3 {
font-size: 14px;
margin: 0;
width: 100%;
text-align: center;
}
/*新闻列表样式*/
.news {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
margin: 20px 0;
}
.news a {
display: flex;
flex-direction: column;
align-items: center;
margin: 10px;
text-align: center;
text-decoration: none;
color: #000;
width: 100%;
}
.news h3 {
font-size: 14px;
margin: 0;
width: 100%;
text-align: center;
}
.news p {
font-size: 12px;
margin: 0;
width: 100%;
text-align: center;
}
/*公司简介样式*/
.about {
margin: 20px 0;
}
.about p {
font-size: 14px;
line-height: 1.5;
margin: 0;
text-align: justify;
text-justify: inter-word;
}
/*管理团队样式*/
.team {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
margin: 20px 0;
}
.team a {
display: flex;
flex-direction: column;
align-items: center;
margin: 10px;
text-align: center;
text-decoration: none;
color: #000;
width: 33.33%;
}
.team img {
width: 80px;
height: 80px;
border-radius: 50%;
margin-bottom: 5px;
}
.team h3 {
font-size: 14px;
margin: 0;
width: 100%;
text-align: center;
}
.team p {
font-size: 12px;
margin: 0;
width: 100%;
text-align: center;
}
/*联系方式样式*/
.contact {
margin: 20px 0;
}
.contact p {
font-size: 14px;
line-height: 1.5;
margin: 0;
text-align: justify;
text-justify: inter-word;
}
</style>
</code></pre>
</head>
<body>
<!--导航条-->
<div class="navbar">
<a href="#home">首页</a>
<a href="#services">服务项目</a>
<a href="#news">新闻动态</a>
<a href="#about">公司简介</a>
<a href="#team">管理团队</a>
<a href="#contact">联系我们</a>
</div>
<pre><code><!--幻灯片-->
<div class="slideshow-container">
<div class="mySlides fade">
<img src="https://picsum.photos/id/237/800/400">
<div class="text">图片标题1</div>
</div>
<div class="mySlides fade">
<img src="https://picsum.photos/id/238/800/400">
<div class="text">图片标题2</div>
</div>
<div class="mySlides fade">
<img src="https://picsum.photos/id/239/800/400">
<div class="text">图片标题3</div>
</div>
<a class="prev" onclick="plusSlides(-1)">&#10094;</a>
<a class="next" onclick="plusSlides(1)">&#10095;</a>
</div>
<br>
<!--图片列表-->
<div class="img-list">
<a href="#" target="_blank">
<img src="https://picsum.photos/id/240/200/150">
<h3>图片标题1</h3>
</a>
<a href="#" target="_blank">
<img src="https://picsum.photos/id/241/200/150">
<h3>图片标题2</h3>
</a>
<a href="#" target="_blank">
<img src="https://picsum.photos/id/242/200/150">
<h3>图片标题3</h3>
</a>
<a href="#" target="_blank">
<img src="https://picsum.photos/id/243/200/150">
<h3>图片标题4</h3>
</a>
<a href="#" target="_blank">
<img src="https://picsum.photos/id/244/200/150">
<h3>图片标题5</h3>
</a>
<a href="#" target="_blank">
<img src="https://picsum.photos/id/245/200/150">
<h3>图片标题6</h3>
</a>
</div>
<!--服务项目-->
<div id="services" class="services">
<a href="#">
<img src="https://picsum.photos/id/246/50/50">
<h3>服务项目1</h3>
</a>
<a href="#">
<img src="https://picsum.photos/id/247/50/50">
<h3>服务项目2</h3>
</a>
<a href="#">
<img src="https://picsum.photos/id/248/50/50">
<h3>服务项目3</h3>
</a>
</div>
<!--新闻列表-->
<div id="news" class="news">
<a href="#">
<h3>新闻标题1</h3>
<p>2022-01-01</p>
</a>
<a href="#">
<h3>新闻标题2</h3>
<p>2022-01-02</p>
</a>
<a href="#">
<h3>新闻标题3</h3>
<p>2022-01-03</p>
</a>
<a href="#">
<h3>新闻标题4</h3>
<p>2022-01-04</p>
</a>
<a href="#">
<h3>新闻标题5</h3>
<p>2022-01-05</p>
</a>
<a href="#">
<h3>新闻标题6</h3>
<p>2022-01-06</p>
</a>
<a href="#">
<h3>新闻标题7</h3>
<p>2022-01-07</p>
</a>
<a href="#">
<h3>新闻标题8</h3>
<p>2022-01-08</p>
</a>
<a href="#">
<h3>新闻标题9</h3>
<p>2022-01-09</p>
</a>
<a href="#">
<h3>新闻标题10</h3>
<p>2022-01-10</p>
</a>
</div>
<!--公司简介-->
<div id="about" class="about">
<p>公司简介内容。</p>
</div>
<!--管理团队-->
<div id="team" class="team">
<a href="#">
<img src="https://picsum.photos/id/249/80/80">
<h3>团队成员1</h3>
<p>职位</p>
</a>
<a href="#">
<img src="https://picsum.photos/id/250/80/80">
<h3>团队成员2</h3>
<p>职位</p>
</a>
<a href="#">
<img src="https://picsum.photos/id/251/80/80">
<h3>团队成员3</h3>
<p>职位</p>
</a>
</div>
<!--联系方式-->
<div id="contact" class="contact">
<p>联系方式内容。</p>
</div>
<script>
//幻灯片自动播放
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName('mySlides');
for (i = 0; i < slides.length; i++) {
slides[i].style.display = 'none';
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
slides[slideIndex-1].style.display = 'block';
setTimeout(showSlides, 2000); // 每隔2秒切换一张图片
}
//幻灯片手动切换
function plusSlides(n) {
showSlidesManual(slideIndex += n);
}
function showSlidesManual(n) {
var i;
var slides = document.getElementsByClassName('mySlides');
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = 'none';
}
slides[slideIndex-1].style.display = 'block';
}
</script>
</code></pre>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/m6Qm 著作权归作者所有。请勿转载和采集!