目录
一、前言
本实例以“美食”蛋糕为主题设计,应用html+css+js,包括图片轮翻效果、点击事件、留言表单等,供大家参考。【关注作者|获取更多源码(2000+个Web案例源码)|优质文章】;您的支持是我创作的动力!【点赞收藏博文】,Web开发、课程设计、毕业设计有兴趣的联系我交流分享,3Q!
二、网页文件
三、网页效果
以下为网页正文(节选示例):
四、代码展示
1.HTML
代码如下(节选示例):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>开始页面</title>
</head>
<style>
html {
height: 100%;
}
body {
background: url(./images/bg.jpg) no-repeat;
background-size: cover;
background-position: bottom;
}
div{
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
h1 {
font-size: 60px;
color: #FAAA00;
text-align: center;
}
a {
color: #fff;
background-color: #FAAA00;
height: 40px;
text-decoration: none;
width: 300px;
display: block;
margin: 0 auto;
line-height: 40px;
font-size: 24px;
border-radius: 5px;
text-align: center;
}
</style>
<body>
<div>
<img src="./images/logo.jpg">
<h1></h1>
<a href="shouye.html">进入</a>
</div>
</body>
</html>
......
2.CSS
代码如下(节选示例):
.flexslider {
margin: 0px auto 20px;
position: relative;
width: 100%;
height: 482px;
overflow: hidden;
zoom: 1;
min-width: 1200px;
}
.flexslider .slides li {
width: 100%;
height: 100%;
}
.flex-direction-nav a {
width: 70px;
height: 70px;
line-height: 99em;
overflow: hidden;
margin: -35px 0 0;
display: block;
background: url(../images/ad_ctr.png) no-repeat;
position: absolute;
top: 50%;
z-index: 10;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: all .3s ease;
border-radius: 35px;
}
.flex-direction-nav .flex-next {
background-position: 0 -70px;
right: 0;
}
.flex-direction-nav .flex-prev {
left: 0;
}
.flexslider:hover .flex-next {
opacity: 0.8;
filter: alpha(opacity=25);
}
.flexslider:hover .flex-prev {
opacity: 0.8;
filter: alpha(opacity=25);
}
.flexslider:hover .flex-next:hover,
.flexslider:hover .flex-prev:hover {
opacity: 1;
filter: alpha(opacity=50);
}
.flex-control-nav {
width: 100%;
position: absolute;
bottom: 10px;
text-align: center;
}
.flex-control-nav li {
margin: 0 2px;
display: inline-block;
zoom: 1;
*display: inline;
}
.flex-control-paging li a {
background: url(../images/dot.png) no-repeat 0 -16px;
display: block;
height: 16px;
overflow: hidden;
text-indent: -99em;
width: 16px;
cursor: pointer;
}
.flex-control-paging li a.flex-active,
.flex-control-paging li.active a {
background-position: 0 0;
}
.flexslider .slides a img {
width: 100%;
height: 482px;
display: block;
}
/*主页内容*/
.content {
position: relative;
width: 1200px;
margin: 0 auto;
}
.ban-boot {
float: left;
margin-top: 60px;
width: 100%;
height: 196px;
}
.ban-zs {
left: 3px;
width: 390px;
height: 196px;
float: left;
margin: 0 5px;
}
.recommand {
float: left;
width: 100%;
}
.rec-nav {
float: left;
margin-top: 60px;
width: 100%;
left: -1px;
height: 48px;
line-height: 48px;
color: #FAAA00;
border-bottom: 2px solid #FAAA00;
}
.rec-nav span {
font-size: 12px;
margin-left: 10px;
color: #999999;
}
.rec-cont {
float: left;
width: 100%;
height: 660px;
margin-top: 40px;
}
.rec-left {
float: left;
width: 320px;
height: 660px;
}
.rec-left img{
width: 100%;
height: 100%;
object-fit: cover;
}
.rec-right {
float: left;
width: 880px;
height: 660px;
}
.rcr {
float: left;
width: 270px;
height: 330px;
margin-left: 23px;
}
.rcr-top {
width: 260px;
height: 200px;
margin-left: 10px;
transition: all 0.5s;
}
.rcr-bot {
width: 260px;
height: 130px;
margin: 0 5px;
}
.rb-top {
width: 260px;
height: 30px;
text-align: center;
font-size: 16px;
border-bottom: 1px dashed #999999;
}
.second_P {
padding-top: 15px;
width: 260px;
height: 20px;
text-align: center;
}
.fk-prop,
.fk-prop-p {
font-size: 12px;
color: #FAAA00;
}
.fk-prop-price {
color: #FAAA00;
font-size: 18px;
}
.second_Marketprice {
color: #767676;
font-size: 12px;
text-decoration: line-through;
}
.buy {
float: left;
width: 100%;
margin-top: 15px;
height: 33px;
line-height: 33px;
text-align: center;
}
......
3.JS
代码如下(节选示例):
$(
(function($, window, document, undefined) {
Slider = function(container, options) {
/*
options = {
auto: true,
time: 3000,
event: 'hover' | 'click',
mode: 'slide | fade',
controller: $(),
activeControllerCls: 'className',
exchangeEnd: $.noop
}
*/
"use strict"; //stirct mode not support by IE9-
if (!container) return;
var options = options || {},
currentIndex = 0,
cls = options.activeControllerCls,
delay = options.delay,
isAuto = options.auto,
controller = options.controller,
event = options.event,
interval,
slidesWrapper = container.children().first(),
slides = slidesWrapper.children(),
length = slides.length,
childWidth = container.width(),
totalWidth = childWidth * slides.length;
function init() {
var controlItem = controller.children();
mode();
event == "hover"
? controlItem
.mouseover(function() {
stop();
var index = $(this).index();
play(index, options.mode);
})
.mouseout(function() {
isAuto && autoPlay();
})
: controlItem.click(function() {
stop();
var index = $(this).index();
play(index, options.mode);
isAuto && autoPlay();
});
isAuto && autoPlay();
}
//animate mode
function mode() {
var wrapper = container.children().first();
options.mode == "slide"
? wrapper.width(totalWidth)
: wrapper
.children()
.css({
position: "absolute",
left: 0,
top: 0
})
.first()
.siblings()
.hide();
}
//auto play
function autoPlay() {
interval = setInterval(function() {
triggerPlay(currentIndex);
}, options.time);
}
//trigger play
function triggerPlay(cIndex) {
var index;
cIndex == length - 1 ? (index = 0) : (index = cIndex + 1);
play(index, options.mode);
}
//play
function play(index, mode) {
slidesWrapper.stop(true, true);
slides.stop(true, true);
mode == "slide"
? (function() {
if (index > currentIndex) {
slidesWrapper.animate(
{
left:
"-=" + Math.abs(index - currentIndex) * childWidth + "px"
},
delay
);
} else if (index < currentIndex) {
slidesWrapper.animate(
{
left:
"+=" + Math.abs(index - currentIndex) * childWidth + "px"
},
delay
);
} else {
return;
}
})()
: (function() {
if (slidesWrapper.children(":visible").index() == index) return;
slidesWrapper
.children()
.fadeOut(delay)
.eq(index)
.fadeIn(delay);
})();
try {
controller.children("." + cls).removeClass(cls);
controller
.children()
.eq(index)
.addClass(cls);
} catch (e) {}
currentIndex = index;
options.exchangeEnd &&
typeof options.exchangeEnd == "function" &&
options.exchangeEnd.call(this, currentIndex);
}
//stop
function stop() {
clearInterval(interval);
}
//prev frame
function prev() {
stop();
currentIndex == 0
? triggerPlay(length - 2)
: triggerPlay(currentIndex - 2);
isAuto && autoPlay();
}
//next frame
function next() {
stop();
currentIndex == length - 1
? triggerPlay(-1)
: triggerPlay(currentIndex);
isAuto && autoPlay();
}
//init
init();
//expose the Slider API
return {
prev: function() {
prev();
},
next: function() {
next();
}
};
};
})(jQuery, window, document)
);
......
五、更多推荐
【关注作者|获取更多源码(2000+个网页源码)|优质文章】;您的支持是我创作的动力!看到这里就【点赞收藏博文】,三连支持下吧,3Q!
Web前端网页制作、整站模板、3D炫酷效果、图片展示、文字效果、大学生毕业HTML、期末大作业模板案例等技术内容,有兴趣的联系我交流学习!
更多优质博客文章、网页模板点击以下链接查阅:仙女网页设计-CSDN博客。