Home Web Front-end HTML Tutorial Detailed explanation of the implementation of the Chinese Valentine's Day confession function in html5+CSS3+JS

Detailed explanation of the implementation of the Chinese Valentine's Day confession function in html5+CSS3+JS

Sep 02, 2017 am 10:01 AM
css javascript

Because today, August 28th, is Chinese Valentine’s Day - Qixi Festival. As a programmer like me, I am not far behind, and I still have a heart to be alone. The following editor has created an implementation based on html5+css3+js for everyone. For the Chinese Valentine's Day special effects and specific example codes, please refer to this article

Because today, August 28, is Chinese Valentine's Day - Chinese Valentine's Day, as a programmer, I can only type code at home! But I still have a heart to be single; I made an h5+css+js interface to wish my friends: Happy Chinese Valentine's Day

The specific functions are:

1. Snowing background animation

2. The following text is displayed verbatim, accompanied by voice

3. The middle image is rotated in 3D

Attached is the source code :


<!doctype html>
<html>
 <head>
  <meta charset="UTF-8">
  <meta name="Keywords" content="关键字,关键词">
  <meta name="Description" content="描述信息">
  <title>七夕快乐</title>
  <!--css 样式 层叠样式表-->
  <style type="text/css">
    *{margin:0;padding:0;}
    html,body{width:100%;height:100%;}
    body{background:url(images/3.jpg);background-size:cover;overflow:hidden;}
    /*top start*/
    .top{width:400px;height:100px;margin:60px auto;font-size:30px;font-family:"华文行楷";color:#fff;}
    /*background:-webkit-linear-gradient(45deg,#ff0000,#ff0099,#ffff00,#33ff00,#3300cc,#000000);*/
    /*end top*/
    /*box start*/
    .box{width:310px;height:310px;margin:auto;perspective:800px;}
    .box .pic{position:relative;transform-style:preserve-3d;/*搭载3d环境*/animation:play 10s linear infinite;}
    /*animation:play 速度 匀速 循环;*/
    .box ul li{list-style:none;position:absolute;top:0;left:0;}
    /*end box*/
    #text{width:500px;height:200px;margin:auto;color:#6fade1;margin:auto;font-size:24px;font-family:"方正喵呜体";}
    /*定义一个关键帧*/
    @keyframes play{
        from{transform:rotateY(0deg);}
        to{transform:rotateY(360deg);}
    }
  </style>
 </head>
 <body>
    <!--top start-->
    <p class="top">
    <!--marquee滚动标签 behaviod="alternate"碰撞-->
    <marquee behavior="alternate">时光不老 我们不散</marquee>
    </p>
    <!--end top-->
    <!--box start-->
    <p class="box">
        <p class="pic">
            <ul>
                <!--图片四要素 src路径 width height alt描述 优化-->
                <li><img src="images/1.png" width="" height="" alt="描述"></li>
                <li><img src="images/2.png" width="" height="" alt="描述"></li>
                <li><img src="images/3.png" width="" height="" alt="描述"></li>
                <li><img src="images/4.png" width="" height="" alt="描述"></li>
                <li><img src="images/5.png" width="" height="" alt="描述"></li>
                <li><img src="images/6.png" width="" height="" alt="描述"></li>
            </ul>
        </p>
    </p>
    <!--end box-->
    <p id="text"></p>
    <!--插入背景音乐-->
    <embed src="周杰伦+-+告白气球.mp3"/>
    <!--引入jQuery类库-->
    <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
    <!--下雪的动画背景 js-->
    <script type="text/javascript" src="js/trans.js"></script>
    <script>
        //拿到每一个li
        $(".pic ul li").each(function(i){
            //每一张图片的旋转角度是不相同的
            var deg=360/$(".pic ul li").size();
        //当前的li对象
        $(this).css({"transform":"rotateY("+deg*i+"deg) translateZ(216px)"});
        //调用下雪的动画
        $.fn.snow({
            minSize:10,
            maxSize:15,
            newOn:500,
            flakeColor:"#fff"
        });
    });
        var i=0;
        var str="把天上的银河截下,汇成爱情的心河,流进你的心里;把天上的鹊桥摘下,变成爱情的心桥,搭在你的心里。给你此生不变的挚爱. 七夕快乐 ! ! !";
        //语音
        var obj = $(&#39;<audio src="http://fanyi.baidu.com/gettts?lan=zh&amp;text=&#39;+str+&#39;&amp;spd=5&amp;sorce=web" autoplay></audio>&#39;);
        $("body").append(obj);
        window.onload= function typing(){
            //获取p
        var myp=document.getElementById("text");
        //实现逐字显示
        myp.innerHTML+=str.charAt(i);
        i++;
        //定时器
        var id = setTimeout(typing,100);
            //判断str显示完后清空setTimeout
            if(i==str.length){
                clearTimeout(id);
            }
        }
    </script>
 </body>
</html>
Copy after login

The above is the detailed content of Detailed explanation of the implementation of the Chinese Valentine's Day confession function in html5+CSS3+JS. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

See all articles