首页 > 分享 > Web网页制作:宠物店(制作三个网页进行联动跳转)

Web网页制作:宠物店(制作三个网页进行联动跳转)

注:用的是IDEA的java语言

1.具体的IDEA布局(可以自己寻找图片去带入)

2.具体的代码实现

style.css

body {

font-family: Arial, sans-serif;

margin: 0;

padding: 0;

line-height: 1.6;

font-size: 18px;

}

a {

text-decoration: none;

color: inherit;

}

header {

display: flex;

justify-content: space-between;

align-items: center;

background-color: #333;

padding: 10px 20px;

}

.logo {

height: 50px;

}

nav ul {

list-style-type: none;

margin: 0;

padding: 0;

display: flex;

}

nav ul li {

margin-right: 15px;

}

nav a {

color: white;

padding: 5px 10px;

border-radius: 5px;

}

nav a.active,

nav a:hover {

background-color: #555;

}

main {

padding: 20px;

}

.banner-section {

position: relative;

text-align: center;

color: white;

}

.banner-image {

width: 100%;

height: 300px;

object-fit: cover;

}

.banner-content {

position: absolute;

top: 50%;

left: 50%;

transform: translate(-50%, -50%);

color: #000000;

}

.featured-pets-section {

margin-bottom: 20px;

}

.pet-pictures-carousel-container {

width: 100%;

height: 300px;

overflow-x: auto;

white-space: nowrap;

border: 1px solid #ccc;

box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);

border-radius: 5px;

}

.pet-carousel-image {

height: 100%;

width: auto;

margin-right: 10px;

}

.product-categories-section,

.product-list-section {

display: flex;

flex-wrap: wrap;

justify-content: flex-start;

}

.contact-info-section,

.contact-form-section,

.location-section {

margin-bottom: 20px;

}

.featured-pet-item,

.product-item {

width: calc(20% - 10px);

margin-bottom: 20px;

text-align: center;

box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);

padding: 10px;

border-radius: 5px;

}

.pet-item,

.product-item {

width: 300px;

margin-bottom: 20px;

text-align: center;

box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);

padding: 10px;

border-radius: 5px;

}

.pet-picture,

.product-picture {

width: 100%;

height: 200px;

object-fit: cover;

border-radius: 5px;

}

.add-to-cart-button,

.submit-button {

background-color: #007bff;

color: white;

padding: 10px 20px;

border-radius: 5px;

margin-top: 10px;

cursor: pointer;

}

.add-to-cart-button:hover,

.submit-button:hover {

background-color: #0056b3;

}

.contact-form-section form {

display: flex;

flex-direction: column;

}

.contact-form-section label {

margin-top: 10px;

}

.contact-form-section input,

.contact-form-section textarea {

padding: 10px;

border: 1px solid #ccc;

border-radius: 5px;

}

.location-section iframe {

margin-top: 20px;

}

footer {

background-color: #333;

color: white;

text-align: center;

padding: 10px;

}

js代码:但是其实不用这个js也能实现页面所显示的功能,可以观察里面滚动字符条的具体结构

window.onload = function() {

const carouselContainer = document.querySelector('.宠物图片轮播容器');

const images = carouselContainer.querySelectorAll('.宠物轮播图片');

const imageWidth = images[0].offsetWidth;

let scrollPosition = 0;

let intervalId;

function autoScroll() {

intervalId = setInterval(function() {

scrollPosition += imageWidth;

if (scrollPosition > carouselContainer.scrollWidth - carouselContainer.offsetWidth) {

scrollPosition = 0;

}

carouselContainer.scrollLeft = scrollPosition;

}, 3000);

}

autoScroll();

carouselContainer.addEventListener('mouseenter', function() {

clearInterval(intervalId);

});

carouselContainer.addEventListener('mouseleave', function() {

autoScroll();

});

window.onload=function(){

function hotChange(){

var current_index=0;

var timer=window.setInterval(autoChange, 3000);

var button_li=document.getElementById("button").getElementsByTagName("li");

var pic_li=document.getElementById("banner_pic").getElementsByTagName("li");

for(var i=0;i<button_li.length;i++){

button_li[i].onmouseover=function(){

if(timer){

clearInterval(timer);

}

for(var j=0;j<pic_li.length;j++){

if(button_li[j]==this){

current_index=j;

button_li[j].className="current";

pic_li[j].className="current";

}else{

pic_li[j].className="pic";

button_li[j].className="but";

}

}

}

button_li[i].onmouseout=function(){

timer=setInterval(autoChange,3000);

}

}

function autoChange(){

++current_index;

if (current_index==button_li.length) {

current_index=0;

}

for(var i=0;i<button_li.length;i++){

if(i==current_index){

button_li[i].className="current";

pic_li[i].className="current";

}else{

button_li[i].className="but";

pic_li[i].className="pic";

}

}

}

}

hotChange();

function school(){

var speed = 50;

var imgbox = document.getElementById("imgbox");

imgbox.innerHTML += imgbox.innerHTML;

var span = imgbox.getElementsByTagName("span");

var timer1 = window.setInterval(marquee,speed);

imgbox.onmouseover = function(){

clearInterval(timer1);

}

imgbox.onmouseout = function(){

timer1=setInterval(marquee,speed);

};

function marquee(){

if(imgbox.scrollLeft > span[0].offsetWidth){

imgbox.scrollLeft = 0;

}else{

++imgbox.scrollLeft;

}

}

}

school();

function tableChange(){

var lis = document.getElementById("SwitchNav").getElementsByTagName("li");

var spans=document.getElementById("SwitchBigPic").getElementsByTagName("span");

var current_index=0;

var timer = setInterval(autoChange,3000);

for(var i=0;i<lis.length;i++){

lis[i].onmouseover = function(){

if(timer){

clearInterval(timer);

}

for(var i=0;i<lis.length;i++){

if(lis[i]==this){

spans[i].className = "sp";

current_index = i;

}else{

spans[i].className = "";

}

}

}

lis[i].onmouseout = function(){

timer = setInterval(autoChange,3000);

}

}

function autoChange(){

++current_index;

if (current_index == lis.length) {

current_index=0;

}

for (var i=0; i<lis.length; i++) {

spans[i].className = "";

}

spans[current_index].className = "sp";

}

}

tableChange();

}

var rotation = document.querySelector('.rotation');

var imgs = rotation.querySelectorAll('img');

var pre = document.querySelector('.pre');

var next = document.querySelector('.next');

var num = 1;

var timer = setInterval(function () {

num++;

if (num == 4) {

num = 1;

}

imgs[0].src = 'image/view' + num + '.jpg';

}, 3000)

rotation.addEventListener('mouseover', function () {

clearInterval(timer);

})

rotation.addEventListener('mouseout', function () {

timer = setInterval(function () {

num++;

if (num == 4) {

num = 1;

}

imgs[0].src = 'image/view' + num + '.jpg';

}, 3000)

})

pre.addEventListener('click', function () {

num--;

if (num == 1) {

num = 4;

}

imgs[0].src = 'image/view' + num + '.jpg';

})

next.addEventListener('click', function () {

num++;

if (num == 4) {

num = 1;

}

imgs[0].src = 'image/view' + num + '.jpg';

})

var heard_top = document.querySelector('.heard_top');

var lis = heard_top.querySelectorAll('li');

var li_boxs = heard_top.querySelectorAll('.li_box');

for(var i=0;i<lis.length;i++){

lis[i].setAttribute('index',i);

lis[i].addEventListener('mouseover',function(){

var index = this.getAttribute('index');

for(var i=0;i<li_boxs.length;i++){

li_boxs[i].style.display='none';

}

li_boxs[index].style.display='block';

})

}

for(var i=0;i<lis.length;i++){

lis[i].addEventListener('mouseout',function(){

for(var i=0;i<li_boxs.length;i++){

li_boxs[i].style.display='none';

}

})

}

3.呈现的三个网页的源代码:

1.主页面

代码:

<!DOCTYPE html>

<html lang="zh-CN">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="css/styles.css">

<script type="text/javascript" src="js/main.js"></script>

<title>Baimeidi Pet Store - Home</title>

</head>

<body>

<header>

<img src="images/店标.jpg" alt="Pet Store Logo" class="logo">

<nav>

<ul>

<li><a href="index.html" class="active">首页</a></li>

<li><a href="products.html">商品</a></li>

<li><a href="contact.html">联系我们</a></li>

</ul>

</nav>

</header>

<main>

<section class="banner-section">

<img src="images/背景.jpg" alt="Pet Store Background" class="banner-image" style="width: 100%; height: 600px; object-fit: cover;">

<div class="banner-content">

<h2>欢迎光临我们的宠物店</h2>

<p>希望你们有一次完美的购物体验 </p>

</div>

</section>

<section class="featured-pets-section">

<h2>特色宠物</h2>

<div class="pet-pictures-carousel-container">

<img src="images/宠物1.jpg" alt="Pet 1" class="pet-carousel-image">

<img src="images/宠物2.jpg" alt="Pet 2" class="pet-carousel-image">

<img src="images/宠物3.jpg" alt="Pet 3" class="pet-carousel-image">

<img src="images/宠物4.jpg" alt="Pet 4" class="pet-carousel-image">

<img src="images/宠物5.png" alt="Pet 5" class="pet-carousel-image">

<img src="images/宠物6.jpg" alt="Pet 6" class="pet-carousel-image">

<img src="images/宠物7.png" alt="Pet 7" class="pet-carousel-image">

<!-- 可以添加更多宠物图片 -->

</div>

</section>

<section class="service-section">

<h2>我们的服务</h2>

<ul>

<li>宠物练习</li>

<li>兽医咨询</li>

<li>宠物锻炼</li>

</ul>

</section>

</main>

<footer>

<p>© 2024 Baimeidi Pet Store. All rights reserved.</p>

</footer>

<script src="js/main.js"></script>

</body>

</html>

2.具体的商品页面(点击右上角商品按钮即可实现)

自己可以多加几类商品

代码:

<!DOCTYPE html>

<html lang="zh-CN">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="css/styles.css">

<title>宠物商品</title>

</head>

<body>

<header>

<img src="images/店标.jpg" alt="Pet Store Logo" class="logo">

<nav>

<ul>

<li><a href="index.html">首页</a></li>

<li><a href="products.html" class="active">商品</a></li>

<li><a href="contact.html">联系我们</a></li>

</ul>

</nav>

</header>

<main>

<section class="product-categories-section">

<h2>产品种类</h2>

<ul>

<li><a href="#">宠物食物</a></li>

<li><a href="#">宠物玩具</a></li>

<li><a href="#">宠物的床</a></li>

<li><a href="#">宠物联系</a></li>

</ul>

</section>

<section class="product-list-section">

<h2>特色产品</h2>

<div class="product-item">

<img src="images/狗粮.jpg" alt="Product 1" class="product-picture">

<h3>好吃的狗粮</h3>

<p>Description: High-quality dog food suitable for all dog breeds.</p>

<p>Price: ¥19.99</p>

<button class="add-to-cart-button">Add to Cart</button>

</div>

<div class="product-item">

<img src="images/猫玩具.jpg" alt="Product 2" class="product-picture">

<h3>逗猫</h3>

<p>Description: Infrared light that cats love most.</p>

<p>Price: ¥29.99</p>

<button class="add-to-cart-button">Add to Cart</button>

</div>

<div class="product-item">

<img src="images/玩具2.gif" alt="Product 2" class="product-picture">

<h3>逗猫</h3>

<p>Description: Kittens also have their own little buddies now.</p>

<p>Price: ¥9.99</p>

<button class="add-to-cart-button">Add to Cart</button>

</div>

<div class="product-item">

<img src="images/玩具3.jpg" alt="Product 2" class="product-picture">

<h3>狗狗最爱的</h3>

<p>Description: Dog's little secret.</p>

<p>Price: ¥9.99</p>

<button class="add-to-cart-button">Add to Cart</button>

</div>

<div class="product-item">

<img src="images/玩具4.jpg" alt="Product 2" class="product-picture">

<h3>犬牙</h3>

<p>Description: No need to worry about damaging the sofa at home anymore.</p>

<p>Price: ¥9.99</p>

<button class="add-to-cart-button">Add to Cart</button>

</div>

<div class="product-item">

<img src="images/玩具5.dpg" alt="Product 2" class="product-picture">

<h3>弹力球</h3>

<p>Description: An excellent helper for testing reaction ability.</p>

<p>Price: ¥9.99</p>

<button class="add-to-cart-button">Add to Cart</button>

</div>

</section>

</main>

<footer>

<p>© 2024 Baimeidi Pet Store. All rights reserved.</p>

</footer>

<script src="js/main.js"></script>

</body>

</html>

3.联系我们 网页

这里输入信息格式错误会报错

还添加了超链接的联动,具体的随便网上的一个地址+地图

内含搜索按钮

代码

<!DOCTYPE html>

<html lang="zh-CN">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="css/styles.css">

<title>Pet Store - Contact Us Page</title>

</head>

<body>

<header>

<img src="images/店标.jpg" alt="Pet Store Logo" class="logo">

<nav>

<ul>

<li><a href="index.html">首页</a></li>

<li><a href="products.html">商品</a></li>

<li><a href="contact.html" class="active">联系我们</a></li>

</ul>

</nav>

</header>

<main>

<section class="contact-info-section">

<h2>联系信息</h2>

<p>地址: No. 123, Pet Street, Zibo City, Shandong Province</p>

<p>电话: (123) 456-7890</p>

<p>邮件: info@宠物店.com</p>

</section>

<section class="contact-form-section">

<h2>邮件信息</h2>

<form action="#" method="post">

<label for="name">你的名字:</label>

<input type="text" id="name" name="name" placeholder="Please enter your name" required>

<label for="email">你的邮件:</label>

<input type="email" id="email" name="email" placeholder="Please enter your email" required>

<label for="message-content">你的留言:</label>

<textarea id="message-content" name="message-content" placeholder="Write your message here" rows="5" required></textarea>

<input type="submit" value="Send Message" class="submit-button">

</form>

</section>

<section class="location-section">

<iframe src="https://zibo.city8.com/life/8a1aap7ehmljb2edb6" width="100%" height="1500" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>

</section>

</main>

<footer>

<p>© 2024 Baimeidi Pet Store. All rights reserved.</p>

</footer>

<script src="js/main.js"></script>

</body>

</html>

相关知识

【web开发网页制作】宠物主题萌宠之家网页制作(4页面)
网页制作的代码
html网页制作——【web前端期末大作业】HTML+CSS宠物狗静态网页设计
dreamweaver作业静态HTML网页设计 大学美食菜谱网页制作教程(web前端网页制作课作业) (1)
HTML网页制作——HTML+CSS宠物狗静态网页设计
大学生网页设计制作作业实例代码 (全网最全,建议收藏) HTML+CSS+JS
制作一个简单HTML宠物猫网页(HTML+CSS)
html网页制作个人网页作业(宠物狗)
382.大学生HTML期末大作业 —【布偶猫宠物主题网页 (7页)】 Web前端网页制作 html+css
校园网页制作代码

网址: Web网页制作:宠物店(制作三个网页进行联动跳转) https://m.mcbbbk.com/newsview1086057.html

所属分类:萌宠日常
上一篇: 幼犬到家不吃狗粮怎么办?
下一篇: 哪里可以批发优质狗粮(宠物店、网