search
HomeWeb Front-endHTML TutorialDetailed explanation of the implementation of the Chinese Valentine's Day confession function in html5+CSS3+JS

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="/static/imghwm/default1.png"  data-src="images/1.png"  class="lazy"      style="max-width:90%" height="" alt="描述"></li>
                <li><img src="/static/imghwm/default1.png"  data-src="images/2.png"  class="lazy"      style="max-width:90%" height="" alt="描述"></li>
                <li><img src="/static/imghwm/default1.png"  data-src="images/3.png"  class="lazy"      style="max-width:90%" height="" alt="描述"></li>
                <li><img src="/static/imghwm/default1.png"  data-src="images/4.png"  class="lazy"      style="max-width:90%" height="" alt="描述"></li>
                <li><img src="/static/imghwm/default1.png"  data-src="images/5.png"  class="lazy"      style="max-width:90%" height="" alt="描述"></li>
                <li><img src="/static/imghwm/default1.png"  data-src="images/6.png"  class="lazy"      style="max-width:90%" 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&text=&#39;+str+&#39;&spd=5&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>

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
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
HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

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

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

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment