• HTML爱心照片墙源码


    HTML爱心照片墙源码

    在这里插入图片描述css

    @charset "utf-8";
    * {
        padding: 0;
        margin: 0;
    }
    div {
        font-family: "微软雅黑";
        font-size: 14px;
        color: #666;
        padding: 0;
        margin: 0;;
    }
    body,html{
        background: black;
        height: 100%;
    }
    /*css3实现照片墙的样式*/
    .container {
        width: 100%;
        height: 100%;
        position: relative;
    	margin: auto;
        background-color: black;
        overflow: hidden;
    }
     
    .container img {
        position: absolute;
        padding: 5px;
        height: 300px;
        width: 300px;
        background: #fff;
        border: 1px solid #ddd;
        -webkit-transition: all 1s ease-in-out;
        -moz-transition: all 1s ease-in-out;
        transition: all 1s ease-in-out;
        z-index: 1;    
        top:50%;
        left:50%;
        -webkit-transform-origin:50% 50%;
        -moz-transform-origin:50% 50%;
        transform-origin:50% 50%;
        -webkit-transform: translate(-50%,-50%) ;
        -moz-transform: translate(-50%,-50%) ;
        transform: translate(-50%,-50%) ;
    }
    .start{
        background-color: blue!important;
        z-index: 4!important;
        -webkit-transition: all 0.2s ease-in-out!important;
        -moz-transition: all 0.2s ease-in-out!important;
        transition: all 0.2s ease-in-out!important;
    }
    .surprise{    
        -webkit-transform-origin:50% 50%!important;
        -moz-transform-origin:50% 50%!important;
        transform-origin:50% 50%!important;
        -webkit-transform: rotate(0deg) translate(-50%,-50%) !important;
        -moz-transform: rotate(0deg) translate(-50%,-50%) !important;
        transform: rotate(0deg) translate(-50%,-50%) !important;   
        /* -webkit-transform:!important;
        -moz- rotate(360deg)transform:rotate(360deg)!important;
        transform:rotate(360deg)!important;    */
        top:50%!important;
        left:50%!important;
        height: 500px!important;
        width: 500px!important;
        z-index: 5!important;
        background-color: red;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70

    html

    DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>照片墙title>
        <link rel="stylesheet" href="./style.css">
    head>
    <body>
        <div class="container" id="container">div>
    	<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">script>
    	<script>
    		$(function () {
    			var count = 0;
    			var selectFlag = false;
    			var startFlag = false;
    			var roundBox;
    			$("#container").css("width", window.innerHeight * 4 / 3)
    			var appendPic = function (item) {
    				if (selectFlag) {
    					return
    				}
    				var x = Math.random() * 4,
    					y = Math.random() * 4
    				if (!heartFunc(x, y)) {
    					appendPic(item)
    				} else {
    					var back = "jpg";
    					var imgNum = 10;
    					if (item % imgNum == 1) {
    						back = "gif"
    					}
    					if (item % imgNum == 2 || item % imgNum == 3 || item % imgNum == 4) {
    						back = "png"
    					}
    					var html = '+ '.png'  + '" class="picBase" id="pic-' + item + '"  />'
    					$("#container").append(html)
    					setTimeout(function () {
    						$("#pic-" + item).css("top", 45 + 25 * (2 - y) * 0.85 + "%").css("left", 50 + 25 * (2 - x) * 0.85 + "%")
    							.css("transform", "rotate("+(25 * (0.5 - Math.random())) + "deg) translate(-50%,-50%)")
    							.css("width", "100px").css("height", "100px")
    					}, 500);
     
    				}
     
    			}
    			var init = function () {
    				for (var i = 1; i < 100; i++) {
    					appendPic(i)
    					count++
    				}		
    			}
    			var selectFunc = function () {
    				$(".surprise").removeClass("surprise").css("transform", "rotate("+(25 * (0.5 - Math.random())) + "deg) ")
    				$("#pic-" + Math.floor(Math.random() * count)).addClass("surprise")		
    				$(".start").removeClass("start")		
    			}
    			var comfirmFunc = function () {				
    				startFunc();
    			}
    			var startFunc = function () {
    				$(".surprise").removeClass("surprise")
    				roundBox= window.setInterval(function(){
    					
    				$(".start").removeClass("start")
    					for (var i = 1; i < count; i++) {
    					if(i%20==Math.floor(Math.random() * 20)){
    						$("#pic-" + i).addClass("start")
    					}					
    				}
    				},200)				
    			}
    			var enterNum=0
    			$(document).keydown(function (e) {
    				selectFlag = true;
    				if (!e) var e = window.event;
    				if (e.keyCode == 32) { //选
    					if(enterNum%2==0){
    						startFunc();
    					}else{			
    						startFlag=true		
    						window.clearInterval(roundBox)					
    						$(".start").removeClass("start")
    						selectFunc();
    					}
    					enterNum++
    					// startFunc();
    				}
    				if (e.keyCode == 13) { //存
    					comfirmFunc();
    				}
    			});
    			var heartFunc = function (x, y) {
    				// console.log(x,y)
    				if (x >= 0 && x < 1) {
    					if (y < (x + 3) && y > (-x + 2)) {
    						return true
    					}
    				} else if (x >= 1 && x < 2) {
    					if (y < (-x + 5) && y > (-x + 2)) {
    						return true
    					}
    				} else if (x >= 2 && x < 3) {
    					if (y < (x + 1) && y > (x - 2)) {
    						return true
    					}
    				} else if (x >= 3 && x < 4) {
    					if (y < (-x + 7) && y > (x - 2)) {
    						return true
    					}
    				}
    				return false
    			}
    			init();
    		})
    	script>
    body>
    html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119

    源码下载:HTML爱心照片墙源码

  • 相关阅读:
    SpringSecurity系列一:01 SpringSecurity 的自动配置原理
    在linux下进行Rabbitmq的yum安装与配置
    Codeforces 1670 E. Hemose on the Tree
    Django REST Framework框架
    Apache JMeter
    T1095 数1的个数(信息学一本通C++)
    【JavaWeb】之文件上传与下载
    Linux知识结构体系简述
    springboot自定义starter集成controller、Dao
    ICC2: secondary pg pin的作用与连接
  • 原文地址:https://blog.csdn.net/Timi2019/article/details/128150474