How to add a page, click in the garden appear blog love with Chinese characters or English

Go to blog from csdn Park just a few days I saw someone else's blog look great on learning a bit and made its own interface;

The first step is to subscribe js

The second step, to change the overall page layout

  1. HTML can be customized online a lot, I think the official's very nice so I did not change, how to find the official interface, first find the blog Set Point Open

2. Locate the following figure page position on opening the double-click you can choose your favorite background

How to add a third click on the page and characters out of love

1. css code characters

//汉字部分的css代码
.text-popup {
    animation: textPopup 1s;
    color: red;
    user-select: none;
    white-space: nowrap;
    position: absolute;
    z-index: 99;
}
@keyframes textPopup {
    0%, 100% {
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    100% {
        transform: translateY(-50px);    
    }
}
</style>

 
 

 

2. Chinese characters js code

var fnTextPopup = function (arr, options) {
    // arr参数是必须的
    if (!arr || !arr.length) {
        return;    
    }
    // 主逻辑
    var index = 0;
    document.documentElement.addEventListener('click', function (event) {
        var x = event.pageX, y = event.pageY;
        var eleText = document.createElement('span');
        eleText.className = 'text-popup';
        this.appendChild(eleText);
        if (arr[index]) {
            eleText.innerHTML = ARR [index]; 
        } the else { 
            index = 0 ; 
            eleText.innerHTML = ARR [0 ]; 
        } 
        // remove the movie ends themselves 
        eleText.addEventListener ( 'the animationEnd' , function () { 
            eleText.parentNode.removeChild (eleText) ; 
        }); 
        // position 
        eleText.style.left = (X - eleText.clientWidth / 2) + 'PX' ; 
        eleText.style.top = (Y - eleText.clientHeight) + 'PX' ;
         // index increment 
        index ++ ; 
    });     
}; 

fnTextPopup ( 
['Prosperity', 'democracy', 'civilization', 'harmony', 'freedom', 'equality', 'fair', 'rule of law', 'patriotism', 'professionalism', 'integrity', 'friendliness']); 

3. Love js code portion

// The following is the code Heart
(function(window,document,undefined){ var hearts = []; window.requestAnimationFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback){ setTimeout(callback,1000/60); } })(); init(); function init(){ css(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}"); attachEvent(); gameloop(); } function gameloop(){ for(var i=0;i<hearts.length;i++){ if(hearts[i].alpha <=0){ document.body.removeChild(hearts[i].el); hearts.splice(i,1); continue; } hearts[i].y--; hearts[i].scale += 0.004; hearts[i].alpha -= 0.013; hearts[i].el.style.cssText = "left:"+hearts[i].x+"px;top:"+hearts[i].y+"px;opacity:"+hearts[i].alpha+";transform:scale("+hearts[i].scale+","+hearts[i].scale+") rotate(45deg);background:"+hearts[i].color; } requestAnimationFrame(gameloop); } function attachEvent(){ var old = typeof window.onclick==="function" && window.onclick; window.onclick = function(event){ old && old(); createHeart(event); } } function createHeart(event){ var d = document.createElement("div"); d.className = "heart"; hearts.push({ el : d, x : event.clientX - 5, y : event.clientY - 5, scale : 1, alpha : 1, color : randomColor() }); document.body.appendChild(d); } function css(css){ var style = document.createElement("style"); style.type="text/css"; try{ style.appendChild(document.createTextNode(css)); }catch(ex){ style.styleSheet.cssText = css; } document.getElementsByTagName('head')[0].appendChild(style); } function randomColor(){ return "rgb("+(~~(Math.random()*255))+","+(~~(Math.random()*255))+","+(~~(Math.random()*255))+")"; } })(window,document);

Note: css code on the side can put blog bulletin board with Chinese characters js part of the love part is in there;

What I can not understand will help you complete the page layout in the bottom comment

4. This part of the code on the wizard can copy directly to the footer if you want to modify the wizard icon just need to find a gif will be replaced with the following code to address

<style>
.spig {
    display:block;
    width:175px;
    height:246px;
    position:absolute;
    bottom: 300px;
    left:180px;
    z-index:9999;
}

#message{
    color :#191919;
    border: 1px solid #c4c4c4;
    background:#ddd;
    -moz-border-radius:5px;
    -webkit-border-radius:5px;
    border-radius:5px;
    min-height:1em;
    padding:5px;
    top:-45px;
    position:absolute;
    text-align:center;
    width:auto !important;
    z-index:10000;
    -moz-box-shadow:0 0 15px #eeeeee;
    -webkit-box-shadow:0 0 15px #eeeeee;
    border-color:#eeeeee;
    box-shadow:0 0 15px #eeeeee;
    outline:none;
}
.mumu{
    width:175px;
    height:246px;
    cursor:move;
    background:url(http://files.cnblogs.com/files/flipped/spig.gif) no-repeat;
}
</style>


<script src="https://blog-static.cnblogs.com/files/ambitionutil/spig.js"></script>
<script src="http://files.cnblogs.com/files/flipped/spig.js"></script>
<!--博客精灵 start*-->
<div id="spig" class="spig">
    <div id="message">……</div>
    <div id="mumu" class="mumu"></div>
</div>

<script type="text/javascript">
var isindex=true;
var title="";
var visitor="这位怪蜀黍";
</script>
<!--精灵end*-->

 

Guess you like

Origin www.cnblogs.com/ambitionutil/p/11240764.html