47.Web前端网页制作 蛋糕店网页设计实例 大学生期末大作业 html+css+js

本文详细介绍了如何运用HTML、CSS和JavaScript创建一个以美食蛋糕为主题的网页,涉及图片轮换、点击交互和留言表单功能。通过实例代码展示了如何构建网页结构和添加动态效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

一、前言

二、网页文件

三、网页效果

四、代码展示

1.HTML

2.CSS

3.JS

五、更多推荐


一、前言

本实例以“美食”蛋糕为主题设计,应用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博客


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

仙女网页制作

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值