Coder往事之: 一些炫酷的特效 for web 前端 (一)

羣星環繞

羣星環繞

html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>星星環繞</title>
        <link rel="stylesheet" href="css/index.css" />
        <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
    </head>
    <body>
        <!--
            作者:[email protected]
            時間:2018-01-09
            描述:羣星環繞
        -->
        <center>
            <h1>我是一個<span>被施了魔法的</span>皮皮怪!</h1>
            <button class="Shine">Hover Me</button>
            <button class="Shine last">Hover Me!!</button>
        </center>
    </body>
</html>

css

.Shine {
  background: #3e5771;
  color: white;
  border: none;
  padding: 16px 36px;
  font-weight: normal;
  border-radius: 3px;
  transition: all 0.25s ease;
  box-shadow: 0 38px 32px -23px black;
  margin: 0 1em 1em;
}
.Shine:hover {
  background: #2c3e50;
  color: rgba(255, 255, 255, 0.2);
}

Js

/*
        Author:[email protected]
        Time:2018-01-09
        Des:羣星環繞
        LastModify:2018年1月9日11:17:01
 */
$(function() {

  // 默認是不同程度的透明白色閃爍
  $(".Shine:first").sparkleh();

  // rainbow用來產生隨機顏色
  // count決定閃閃發光的數量
  // overlap決定閃爍點的移動,不過要小心其他的dom事件.
  $(".Shine:last").sparkleh({
    color: "rainbow",
    count: 100,
    overlap: 10
  });

  // 在這裏創建了Fuscia閃爍
  $("h1").sparkleh({
    count: 80,
    color: "#ff0080"
  });

  $("p").sparkleh({
    count: 20,
    color: "#00ff00"
  });

  // color也可以是數組
  // 對於image,需要完全加載才能設置
  // canvas的高度或者寬度 
  $("#image").imagesLoaded( function() {
    $(".img").sparkleh({
      count: 25,
      color: ["#00afec","#fb6f4a","#fdfec5"]
    });
  });

});

$.fn.sparkleh = function( options ) {

  return this.each( function(k,v) {

    var $this = $(v).css("position","relative");

    var settings = $.extend({
      width: $this.outerWidth(),
      height: $this.outerHeight(),
      color: "#FFFFFF",
      count: 30,
      overlap: 0
    }, options );

    var sparkle = new Sparkle( $this, settings );

    $this.on({
      "mouseover focus" : function(e) {
        sparkle.over();
      },
      "mouseout blur" : function(e) {
        sparkle.out();
      }
    });

  });

}

function Sparkle( $parent, options ) {
  this.options = options;
  this.init( $parent );
}

Sparkle.prototype = {

  "init" : function( $parent ) {

    var _this = this;

    this.$canvas = 
      $("<canvas>")
        .addClass("sparkle-canvas")
        .css({
          position: "absolute",
          top: "-"+_this.options.overlap+"px",
          left: "-"+_this.options.overlap+"px",
          "pointer-events": "none"
        })
        .appendTo($parent);

    this.canvas = this.$canvas[0];
    this.context = this.canvas.getContext("2d");
    this.sprite = new Image();

    this.canvas.width = this.options.width + ( this.options.overlap * 2);
    this.canvas.height = this.options.height + ( this.options.overlap * 2);

    this.sprites = [0,6,13,20];
    this.particles = this.createSparkles( this.canvas.width , this.canvas.height );

    this.anim = null;
    this.fade = false;

  },

  "createSparkles" : function( w , h ) {

    var holder = [];

    for( var i = 0; i < this.options.count; i++ ) {

      var color = this.options.color;

      if( this.options.color == "rainbow" ) {
        color = '#'+Math.floor(Math.random()*16777215).toString(16);
      } else if( $.type(this.options.color) === "array" ) {
        color = this.options.color[ Math.floor(Math.random()*this.options.color.length) ];
      }

      holder[i] = {
        position: {
          x: Math.floor(Math.random()*w),
          y: Math.floor(Math.random()*h)
        },
        style: this.sprites[ Math.floor(Math.random()*4) ],
        delta: {
          x: Math.floor(Math.random() * 1000) - 500,
          y: Math.floor(Math.random() * 1000) - 500
        },
        size: parseFloat((Math.random()*2).toFixed(2)),
        color: color
      };

    }

    return holder;

  },

  "draw" : function( time, fade ) {

    var ctx = this.context;
    var img = this.sprite;
        img.src = this.datauri;

    ctx.clearRect( 0, 0, this.canvas.width, this.canvas.height );

    for( var i = 0; i < this.options.count; i++ ) {

      var derpicle = this.particles[i];
      var modulus = Math.floor(Math.random()*7);

      if( Math.floor(time) % modulus === 0 ) {
        derpicle.style = this.sprites[ Math.floor(Math.random()*4) ];
      }

      ctx.save();
      ctx.globalAlpha = derpicle.opacity;
      ctx.drawImage(img, derpicle.style, 0, 7, 7, derpicle.position.x, derpicle.position.y, 7, 7);

      if( this.options.color ) {  

        ctx.globalCompositeOperation = "source-atop";
        ctx.globalAlpha = 0.5;
        ctx.fillStyle = derpicle.color;
        ctx.fillRect(derpicle.position.x, derpicle.position.y, 7, 7);

      }

      ctx.restore();

    }

  },

  "update" : function() {

     var _this = this;

     this.anim = window.requestAnimationFrame( function(time) {

       for( var i = 0; i < _this.options.count; i++ ) {

         var u = _this.particles[i];

         var randX = ( Math.random() > Math.random()*2 );
         var randY = ( Math.random() > Math.random()*3 );

         if( randX ) {
           u.position.x += (u.delta.x / 1500); 
         }        

         if( !randY ) {
           u.position.y -= (u.delta.y / 800);         
         }

         if( u.position.x > _this.canvas.width ) {
           u.position.x = -7;
         } else if ( u.position.x < -7 ) {
           u.position.x = _this.canvas.width; 
         }

         if( u.position.y > _this.canvas.height ) {
           u.position.y = -7;
           u.position.x = Math.floor(Math.random()*_this.canvas.width);
         } else if ( u.position.y < -7 ) {
           u.position.y = _this.canvas.height; 
           u.position.x = Math.floor(Math.random()*_this.canvas.width);
         }

         if( _this.fade ) {
           u.opacity -= 0.02;
         } else {
           u.opacity -= 0.005;
         }

         if( u.opacity <= 0 ) {
           u.opacity = ( _this.fade ) ? 0 : 1;
         }

       }

       _this.draw( time );

       if( _this.fade ) {
         _this.fadeCount -= 1;
         if( _this.fadeCount < 0 ) {
           window.cancelAnimationFrame( _this.anim );
         } else {
           _this.update(); 
         }
       } else {
         _this.update();
       }

     });

  },

  "cancel" : function() {

    this.fadeCount = 100;

  },

  "over" : function() {

    window.cancelAnimationFrame( this.anim );

    for( var i = 0; i < this.options.count; i++ ) {
      this.particles[i].opacity = Math.random();
    }

    this.fade = false;
    this.update();

  },

  "out" : function() {

    this.fade = true;
    this.cancel();

  },

  "datauri" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAHCAYAAAD5wDa1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozNDNFMzM5REEyMkUxMUUzOEE3NEI3Q0U1QUIzMTc4NiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDozNDNFMzM5RUEyMkUxMUUzOEE3NEI3Q0U1QUIzMTc4NiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjM0M0UzMzlCQTIyRTExRTM4QTc0QjdDRTVBQjMxNzg2IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjM0M0UzMzlDQTIyRTExRTM4QTc0QjdDRTVBQjMxNzg2Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+jzOsUQAAANhJREFUeNqsks0KhCAUhW/Sz6pFSc1AD9HL+OBFbdsVOKWLajH9EE7GFBEjOMxcUNHD8dxPBCEE/DKyLGMqraoqcd4j0ChpUmlBEGCFRBzH2dbj5JycJAn90CEpy1J2SK4apVSM4yiKonhePYwxMU2TaJrm8BpykpWmKQ3D8FbX9SOO4/tOhDEG0zRhGAZo2xaiKDLyPGeSyPM8sCxr868+WC/mvu9j13XBtm1ACME8z7AsC/R9r0fGOf+arOu6jUwS7l6tT/B+xo+aDFRo5BykHfav3/gSYAAtIdQ1IT0puAAAAABJRU5ErkJggg=="

}; 

// $('img.photo',this).imagesLoaded(myFunction)
// 因爲.load()不適用於緩存的圖像,所以所有圖像加載完成後執行回調.

// 回調函數傳遞最後一個圖像作爲參數加載,集合爲`this`

$.fn.imagesLoaded = function(callback){
  var elems = this.filter('img'),
      len   = elems.length,
      blank = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";

  elems.bind('load.imgloaded',function(){
      if (--len <= 0 && this.src !== blank){ 
        elems.unbind('load.imgloaded');
        callback.call(elems,this); 
      }
  }).each(function(){
     // 緩存的圖像有時不會觸發負載,所以我們重置src.
     if (this.complete || this.complete === undefined){
        var src = this.src;
        this.src = blank;
        this.src = src;
     }  
  }); 

  return this;
};

雪花飄落

這裏寫圖片描述

html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>雪花飄落</title>
        <link rel="apple-touch-icon" href="images/apple-touch-icon.png" />
        <!-- The leaves.css file animates the leaves -->
        <link rel="stylesheet" href="css/SnowFall.css" type="text/css" media="screen" charset="utf-8">
        <!-- The leaves.js file creates the leaves -->
        <script src="js/SnowFall.js" type="text/javascript" charset="utf-8"></script>
    </head>
    <body>
        <!--
            作者:[email protected]
            時間:2018-01-09
            描述:雪花飄落
        -->
        <div id="container">
            <!-- The container is dynamically populated using the init function in leaves.js -->
            <!-- Its dimensions and position are defined using its id selector in leaves.css -->
            <div id="leafContainer"></div>
            <!-- its appearance, dimensions, and position are defined using its id selector in leaves.css -->
        </div>
    </body>
</html>

css

/*
        Author:[email protected]
        Time:2018-01-09
        Des:雪花飄落
        LastModify: 2018年1月9日12:07:03
 */

body
{
    background-color: #fff;
}

#container {
    position: relative;
    height: 90vh;
    width: 90vw;
    margin: 10px auto;
    overflow: hidden;
    border: 4px solid #ccc;
}

/* Defines the position and dimensions of the leafContainer div */
#leafContainer 
{
    position: absolute;
    width: 100%;
    height: 100%;
}

/* Sets the color of the "Dino's Gardening Service" message */
em 
{
    font-weight: bold;
    font-style: normal;
}

/* This CSS rule is applied to all div elements in the leafContainer div.
   It styles and animates each leafDiv.
*/
#leafContainer > div 
{
    position: absolute;
    width: 100px;
    height: 100px;

    /* We use the following properties to apply the fade and drop animations to each leaf.
       Each of these properties takes two values. These values respectively match a setting
       for fade and drop.
    */
    -webkit-animation-iteration-count: infinite, infinite;
    -webkit-animation-direction: normal, normal;
    -webkit-animation-timing-function: linear, ease-in;
}

/* This CSS rule is applied to all img elements directly inside div elements which are
   directly inside the leafContainer div. In other words, it matches the 'img' elements
   inside the leafDivs which are created in the createALeaf() function.
*/
#leafContainer > div > img {
     position: absolute;
     width: 50px;
     height: 50px;

    /* We use the following properties to adjust the clockwiseSpin or counterclockwiseSpinAndFlip
       animations on each leaf.
       The createALeaf function in the Leaves.js file determines whether a leaf has the 
       clockwiseSpin or counterclockwiseSpinAndFlip animation.
    */
     -webkit-animation-iteration-count: infinite;
     -webkit-animation-direction: alternate;
     -webkit-animation-timing-function: ease-in-out;
     -webkit-transform-origin: 50% -100%;
}


/* Hides a leaf towards the very end of the animation */
@-webkit-keyframes fade
{
    /* Show a leaf while into or below 95 percent of the animation and hide it, otherwise */
    0%   { opacity: 1; }
    95%  { opacity: 1; }
    100% { opacity: 0; }
}


/* Makes a leaf fall from -300 to 600 pixels in the y-axis */
@-webkit-keyframes drop
{
    /* Move a leaf to -300 pixels in the y-axis at the start of the animation */
    0%   { -webkit-transform: translate(0px, -50px); }
    /* Move a leaf to 600 pixels in the y-axis at the end of the animation */
    100% { -webkit-transform: translate(0px, 850px); }
}

/* Rotates a leaf from -50 to 50 degrees in 2D space */
@-webkit-keyframes clockwiseSpin
{
    /* Rotate a leaf by -50 degrees in 2D space at the start of the animation */
    0%   { -webkit-transform: rotate(-50deg); }
    /*  Rotate a leaf by 50 degrees in 2D space at the end of the animation */
    100% { -webkit-transform: rotate(50deg); }
}


/* Flips a leaf and rotates it from 50 to -50 degrees in 2D space */
@-webkit-keyframes counterclockwiseSpinAndFlip 
{
    /* Flip a leaf and rotate it by 50 degrees in 2D space at the start of the animation */
    0%   { -webkit-transform: scale(-1, 1) rotate(50deg); }
    /* Flip a leaf and rotate it by -50 degrees in 2D space at the end of the animation */
    100% { -webkit-transform: scale(-1, 1) rotate(-50deg); }
}

Js

/*
        Author:[email protected]
        Time:2018-01-09
        Des:雪花飄落
        LastModify: 2018年1月9日12:07:03
 */

const NUMBER_OF_LEAVES = 60;
/* 
    Called when the "Falling Leaves" page is completely loaded.
*/
function init()
{
    /* Get a reference to the element that will contain the leaves */
    var container = document.getElementById('leafContainer');
    /* Fill the empty container with new leaves */
    for (var i = 0; i < NUMBER_OF_LEAVES; i++) 
    {
        container.appendChild(createALeaf());
    }
}
/*
    Receives the lowest and highest values of a range and
    returns a random integer that falls within that range.
*/
function randomInteger(low, high)
{
    return low + Math.floor(Math.random() * (high - low));
}
/*
   Receives the lowest and highest values of a range and
   returns a random float that falls within that range.
*/
function randomFloat(low, high)
{
    return low + Math.random() * (high - low);
}


/*
    Receives a number and returns its CSS pixel value.
*/
function pixelValue(value)
{
    return value + 'vw';
}


/*
    Returns a duration value for the falling animation.
*/

function durationValue(value)
{
    return value + 's';
}


/*
    Uses an img element to create each leaf. "Leaves.css" implements two spin 
    animations for the leaves: clockwiseSpin and counterclockwiseSpinAndFlip. This
    function determines which of these spin animations should be applied to each leaf.

*/
function createALeaf()
{
    /* Start by creating a wrapper div, and an empty img element */
    var leafDiv = document.createElement('div');
    var image = document.createElement('img');

    /* Randomly choose a leaf image and assign it to the newly created element */
    //image.src = 'images/realLeaf' + randomInteger(1, 5) + '.png';
    image.src = 'img/Snow.png';

    leafDiv.style.top = "-50px";

    /* Position the leaf at a random location along the screen */
    leafDiv.style.left = pixelValue(randomInteger(0, 90));

    /* Randomly choose a spin animation */
    var spinAnimationName = (Math.random() < 0.5) ? 'clockwiseSpin' : 'counterclockwiseSpinAndFlip';

    /* Set the -webkit-animation-name property with these values */
    leafDiv.style.webkitAnimationName = 'fade, drop';
    image.style.webkitAnimationName = spinAnimationName;

    /* Figure out a random duration for the fade and drop animations */
    var fadeAndDropDuration = durationValue(randomFloat(5, 11));

    /* Figure out another random duration for the spin animation */
    var spinDuration = durationValue(randomFloat(4, 8));
    /* Set the -webkit-animation-duration property with these values */
    leafDiv.style.webkitAnimationDuration = fadeAndDropDuration + ', ' + fadeAndDropDuration;

    var leafDelay = durationValue(randomFloat(0, 5));
    leafDiv.style.webkitAnimationDelay = leafDelay + ', ' + leafDelay;

    image.style.webkitAnimationDuration = spinDuration;

    // add the <img> to the <div>
    leafDiv.appendChild(image);

    /* Return this img element so it can be added to the document */
    return leafDiv;
}


/* Calls the init function when the "Falling Leaves" page is full loaded */
window.addEventListener('load', init, false);

閃耀按鈕

閃耀按鈕

html

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title>閃光按鈕</title>
        <link rel="stylesheet" href="css/ShineBtn.css" />
    </head>
    <body id="radioactiveButtonsPage" class="chrome windows">
        <div class="wall-of-buttons">
            <a class="large green button">路飛</a>
            <a class="large blue button">黑崎一護</a>
            <a class="large magenta button">白鬍子</a>
            <a class="large green button">朽木露琪亞</a>
            <a class="large red button">藍染</a>
            <a class="large magenta button">井上織姬</a>
            <br />

            <a class="large orange button">野比大雄</a>
            <a class="large magenta button">剛田武胖虎</a>
            <a class="large green button">骨川小夫</a>
            <a class="large orangellow button">源靜香</a>
            <a class="large blue button">哆啦A夢</a>
            <a class="large red button">夏目友人帳</a>
            <a class="large blue button">娘口三三</a>
            <br />

            <a class="large magenta button">阪本</a>
            <a class="large orangellow button">出木杉</a>
            <a class="large red button">哆啦小子</a>
            <a class="large orange button">哆啦王</a>
            <a class="large green button">哆啦尼可夫</a>
            <a class="large orangellow button">哆啦利鈕</a>
            <a class="large red button">哆啦梅度三世</a>

            <a class="large blue button">耶魯馬他哆啦</a>
            <a class="large orangellow button">御阪美琴</a>
            <a class="large blue button">利威爾·阿克曼</a>
            <a class="large red button">叶音竹</a>
            <a class="large orange button">蕭炎</a>
            <a class="large orangellow button">美少女戰士</a>
        </div>
    </body>

</html>

Css


body {
                background: #333;
                text-shadow: 0 1px 1px rgba(0, 0, 0, .5);
            }

            @-webkit-keyframes bigAssButtonPulse {
                from {
                    background-color: #749a02;
                    -webkit-box-shadow: 0 0 25px #333;
                }
                50% {
                    background-color: #91bd09;
                    -webkit-box-shadow: 0 0 50px #91bd09;
                }
                to {
                    background-color: #749a02;
                    -webkit-box-shadow: 0 0 25px #333;
                }
            }

            @-webkit-keyframes greenPulse {
                from {
                    background-color: #749a02;
                    -webkit-box-shadow: 0 0 9px #333;
                }
                50% {
                    background-color: #91bd09;
                    -webkit-box-shadow: 0 0 18px #91bd09;
                }
                to {
                    background-color: #749a02;
                    -webkit-box-shadow: 0 0 9px #333;
                }
            }

            @-webkit-keyframes bluePulse {
                from {
                    background-color: #007d9a;
                    -webkit-box-shadow: 0 0 9px #333;
                }
                50% {
                    background-color: #2daebf;
                    -webkit-box-shadow: 0 0 18px #2daebf;
                }
                to {
                    background-color: #007d9a;
                    -webkit-box-shadow: 0 0 9px #333;
                }
            }

            @-webkit-keyframes redPulse {
                from {
                    background-color: #bc330d;
                    -webkit-box-shadow: 0 0 9px #333;
                }
                50% {
                    background-color: #e33100;
                    -webkit-box-shadow: 0 0 18px #e33100;
                }
                to {
                    background-color: #bc330d;
                    -webkit-box-shadow: 0 0 9px #333;
                }
            }

            @-webkit-keyframes magentaPulse {
                from {
                    background-color: #630030;
                    -webkit-box-shadow: 0 0 9px #333;
                }
                50% {
                    background-color: #a9014b;
                    -webkit-box-shadow: 0 0 18px #a9014b;
                }
                to {
                    background-color: #630030;
                    -webkit-box-shadow: 0 0 9px #333;
                }
            }

            @-webkit-keyframes orangePulse {
                from {
                    background-color: #d45500;
                    -webkit-box-shadow: 0 0 9px #333;
                }
                50% {
                    background-color: #ff5c00;
                    -webkit-box-shadow: 0 0 18px #ff5c00;
                }
                to {
                    background-color: #d45500;
                    -webkit-box-shadow: 0 0 9px #333;
                }
            }

            @-webkit-keyframes orangellowPulse {
                from {
                    background-color: #fc9200;
                    -webkit-box-shadow: 0 0 9px #333;
                }
                50% {
                    background-color: #ffb515;
                    -webkit-box-shadow: 0 0 18px #ffb515;
                }
                to {
                    background-color: #fc9200;
                    -webkit-box-shadow: 0 0 9px #333;
                }
            }

            a.button {
                -webkit-animation-duration: 2s;
                -webkit-animation-iteration-count: infinite;
            }

            .green.button {
                -webkit-animation-name: greenPulse;
                -webkit-animation-duration: 3s;
            }

            .blue.button {
                -webkit-animation-name: bluePulse;
                -webkit-animation-duration: 4s;
            }

            .red.button {
                -webkit-animation-name: redPulse;
                -webkit-animation-duration: 1s;
            }

            .magenta.button {
                -webkit-animation-name: magentaPulse;
                -webkit-animation-duration: 2s;
            }

            .orange.button {
                -webkit-animation-name: orangePulse;
                -webkit-animation-duration: 3s;
            }

            .orangellow.button {
                -webkit-animation-name: orangellowPulse;
                -webkit-animation-duration: 5s;
            }

            .wall-of-buttons {
                width: 100%;
                height: 180px;
                text-align: center;
            }

            .wall-of-buttons a.button {
                display: inline-block;
                margin: 0 10px 9px 0;
            }

.button {
    display: inline-block;
    padding: 5px 15px 6px;
    color: #fff !important;
    font-size: 13px;
    font-weight: bold;
    line-height: 1;
    text-decoration: none;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(0, 0, 0, 0.25);
    position: relative;
    cursor: pointer;
    overflow: visible;
    width: auto;
}

button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

.button:hover {
    background-color: #111;
    color: #fff;
}

.button:active {
    -webkit-transform: translateY(1px);
    -moz-transform: translateY(1px);
}


/* Small Buttons */

.small.button {
    font-size: 11px;
}


/* Large Buttons */

.large.button {
    font-size: 14px;
    padding: 8px 19px 9px;
}


/* Colors for our beloved buttons */

.green.button {
    background-color: #91bd09;
}

.green.button:hover {
    background-color: #749a02;
}

.blue.button {
    background-color: #2daebf;
}

.blue.button:hover {
    background-color: #007d9a;
}

.red.button {
    background-color: #e33100;
}

.red.button:hover {
    background-color: #872300;
}

.magenta.button {
    background-color: #a9014b;
}

.magenta.button:hover {
    background-color: #630030;
}

.orange.button {
    background-color: #ff5c00;
}

.orange.button:hover {
    background-color: #d45500;
}

.orangellow.button {
    background-color: #ffb515;
}

.orangellow.button:hover {
    background-color: #fc9200;
}

.white.button {
    background-color: #fff;
    border: 1px solid #ccc;
    color: #666 !important;
    font-weight: normal;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 1);
}

.white.button:hover {
    background-color: #eee;
}


/*Strike button*/

.strike.button {
    background-color: #4ADFC1
}

.strike.button:hover {
    background-color: #39ceb0
}


/* Secondary buttons (perfect for Cancels or other secondary actions */

.secondary.button {
    background: #fff url(/images/gradients/36px-black.png) repeat-x 0 0;
    color: #555 !important;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
    border: 1px solid #bbb;
    -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.secondary.button:hover {
    background-color: #eee;
    color: #444 !important;
    border-color: #999;
}


/* Make the buttons super awesomer */

.super.button {
    background-image: url(/images/super-button-overlay.png);
    font-size: 13px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, .25);
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
}

.super.button span {
    display: block;
    padding: 4px 15px 6px;
    -webkit-border-radius: 14px;
    -moz-border-radius: 14px;
    border-top: 1px solid rgba(255, 255, 255, .2);
    line-height: 1;
}

.small.super.button {
    font-size: 11px;
    -webkit-border-radius: 12px;
    -moz-border-radius: 12px;
}

.small.super.button span {
    padding: 2px 12px 6px;
    -webkit-border-radius: 11px;
    -moz-border-radius: 11px;
}

.small.white.super.button span {
    padding: 3px 12px 5px;
}

.large.super.button {
    background-position: left bottom;
    -webkit-border-radius: 18px;
    -moz-border-radius: 18px;
}

.large.super.button span {
    font-size: 14px;
    padding: 7px 20px 9px;
    -webkit-border-radius: 17px;
    -moz-border-radius: 17px;
}

抽卡

抽卡

(PS: 想要背景大圖的加Q: 352183987)

html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>抽卡</title>
        <link rel="stylesheet" href="css/card.css" />
        <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div class="folder">
                <div class="paper">
                    <h1>なつめ ゆうじん ちょう</h1>
                    <p>我想成爲一個溫柔的人,因爲曾被溫柔的人那樣對待,深深瞭解那種被溫柔相待的感覺.</p>
                    <p>所看到的東西未必存在,沒有人理解我獨自行走在那個不安定世界的恐懼。所看到的東西或許也不存在,那個不安定的世界.</p>
                    <p>我喜歡溫柔,也喜歡溫暖,所以我喜歡人類.</p>
                </div>
                <div class="cover">
                    <div class="title">夏目友人帳</div>
                </div>
            </div>
        </div>

    </body>
</html>

Css

/*
    Author:[email protected]
    Time:2018-01-09
    Des:抽卡
    LastModify: 2018年1月9日16:00:17
 */
*, *:before, *:after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  background: url(../img/XM.jpg);
  margin: 0;
  padding: 0;
}

.container {
  position: relative;
  width: 100%;
  height: 100%;
}
.container > .folder {
  width: 220px;
  height: 180px;
  left: calc(50% - 110px);
  top: calc(70% - 90px);
  position: absolute;
}
.container > .folder > .cover {
  cursor: pointer;
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: #fab62f;
  -moz-border-radius: 0 0 10px 10px;
  -webkit-border-radius: 0;
  border-radius: 0 0 10px 10px;
  -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.2);
  -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.2);
  box-shadow: 5px 5px rgba(0, 0, 0, 0.2);
}
.container > .folder > .cover:before, .container > .folder > .cover:after {
  box-sizing: border-box;
  content: "";
  display: block;
  position: absolute;
  top: -100px;
  border: 50px solid transparent;
}
.container > .folder > .cover:before {
  left: 0;
  width: 50%;
  border-left: none;
  border-bottom-color: #fab62f;
}
.container > .folder > .cover:after {
  right: 0;
  width: 50%;
  border-right: none;
  border-bottom-color: #fab62f;
}
.container > .folder > .cover > .title {
  position: absolute;
  padding: 1em;
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-weight: bold;
  text-align: center;
  font-size: 2.5em;
  color: rgba(0, 0, 0, 0.1);
  -moz-user-select: -moz-none;
  -ms-user-select: none;
  -webkit-user-select: none;
  user-select: none;
  -moz-transform: rotate(20deg);
  -ms-transform: rotate(20deg);
  -o-transform: rotate(20deg);
  -webkit-transform: rotate(20deg);
  transform: rotate(20deg);
}
.container > .folder > .paper {
  opacity: 1;
  position: absolute;
  overflow: hidden;
  width: 200px;
  height: 200px;
  top: calc(50% - 150px);
  left: calc(50% - 100px);
  transition: top 0.5s, opacity 0.4s;
  font-family: Verdana, Tahoma, sans-serif;
  font-size: 0.1em;
  padding: 1em;
  color: #644812;
  background-color: #fde1ab;
  -moz-box-shadow: 10px 10px rgba(0, 0, 0, 0.2);
  -webkit-box-shadow: 10px 10px rgba(0, 0, 0, 0.2);
  box-shadow: 10px 10px rgba(0, 0, 0, 0.2);
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
}
.container > .folder:hover > .paper {
  top: calc(50% - 200px);
}
.container > .folder.opened > .paper {
  top: calc(-500px);
  opacity: 0;
}

Js

$(document).on('click', '.folder', function() {
    $(this).toggleClass('opened');
});
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章